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 motor that I reckon is better suited to the task. Instead of using brushed motors that are cheaper, I have found 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, which simplifies things and reduces interface costs.
- Motors have built-in encoder disks, 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 use seem to be manufactured for Ricoh, but I have not yet obtained any decent technical information. However, they are sold as 20W brushless motors with built-in driver electronics and a quadrature encoder.
While they cost around $15 each, these motors have a brilliant behavior, even when powered at 12V (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.
Another interesting detail is that motor electronics will work at 3.3V, too, in case you are driving it from a 3V3 processor. But remember, the output shaft is 6mm and not 5mm, which is a bit of a pain.
Comments
I am not familiar with that processor model. Source code is in my github and most likely can be adapted (have a look at the ATtiny85 code available there): https://github.com/misan/dcservo/blob/master/attiny85.ino