One Arduino controlling two brushless DC motors
After some changes I have been able to get it working reliably with two motors. But one of the changes I have made is to use a new type of motors that I reckon are better suited to the task. Instead of using brushed motors that are cheaper, I have found these other brushless motors that have several advantages:
- Being brushless there is no other wear than the bearings
- They have built-in driving electronics, so they can be controlled with the Arduino digital outputs, that simplifies things and reduces interface cost.
- Motors have built-in encoder disk too, but the one they carry is just 100 lines per revolution (a bit poor in my opinion) that can turn into 400 "steps" per revolution with the 4x decoding of the program. The lower number of lines per revolution puts less stress on the Arduino interrupt code, which may be one of the reasons it works ok now.
- I have moved all the encoder signals to pins that are monitored with the interrupt on pin change and I have reserved the two external interrupts for the STEP input signals for each motor.
The motors I am using seem to be manufactured for Ricoh, but I have failed so far to obtain any decent technical information. But they are sold as 20W brushless motors with built-in driver electronics and quadrature encoder.
While they cost around $15 each, these motors have a brilliant behavior, even when powered at 12V (they are rated 24V). With power to spare I have to reduce the PID maximum output if I do not want my toothed pulleys to skip in the highest acceleration moves of my tests. The video below shows X and Y axis motion while printing a part controlled with Marlin firmware running on the blue Mega board while the red Arduino UNO board runs this code.
Some other interesting detail is that motor electronics will work at 3.3V too, in case you are driving it from a 3V3 processor. But remember output shaft is 6mm and not 5mm which is a bit of a pain.