Doubts about driving/controlling a DC servo motor

I tried to search the internet, but some doubt still remains.

I'm realizing with Arduino a DC servo motor (i.e. not a stepper motor) driver/controller which generates the two PWM pulses for an h-bridge and acquires the two pulses of a quadrature encoder and the analog output of a current sensor. The aim is to implement a simple PID control to drive the motor to the requested position (position control), at the selected speed (speed control) or with the specified current (current/torque control).

Here are the questions:

  1. Considering that the first application in which it will be used will be a CNC milling machine and, so, that a gcode parser shall be integrated in the code, will one only Arduino board be enough (in terms of resources) or will i need one board per motor (three in total)? In this last case, how it will be possible to synchronize the gcode commands generated by a single source (a PC) and sent to the three different boards?
  2. How the motor position can be held in order to block it while movements on other axes are in progress?

Thanks, that's all for the moment. Ciao!

I think a Mega is required in the first place because of the multiplicity of signals involved in a CNC machine, and that means you have a reasonable number of input interrupt and pin-change interrupt capable pins. You also have lots of timers for generating PWM too, so it doesn't strike me as impossible with one board.

I would suggest use an Uno or Mega to implement one servo motor feedback loop and take stock of how much CPU time and interrupt latency you have left to play with.

[ either one Mega for everything, or one Mega coordinating some Pro-Minis ]

I've done a very similar thing but driving 3-phase motor, and used a PWM pin as a pin-change interrupt trigger to allow me to perform multiple pin-driving in antiphase from one PWM channel with some conditional logic. That was a bit resource hungry with 16k interrupts/second (not counting encoder pulses), but it works fine.

You could greatly reduce the computational load on the Arduino by interpreting the GCode on the PC and just sending data for the numbers of steps to the Arduino. The Arduino can act as a buffer to eliminate problems due to USB latency by storing two or three sets of instructions in addition to the set being implemented.