I have a project in which I need to control a small 3 phase motor with something like an Uno, and I from the research I've done I understand that I probably need something like a L6234 to drive the coils. However, here the current to the three phases is controlled by PWM, and I understand that PWM output is 8 bit on the Arduino (16 bits for one pin?) and I need finer control. Is there a straight-forward way that I can write to 3 pins with 16-bit PWM signal? Ideally I would have some room left over to read from an encoder for feedback.
I thought about using a 16-bit DAC as an intermediary (like AD5667), but each of these would eat up 3 pins, and the moreover, this just controls the voltage, not the current. Digital electronics is obviously not my strong point, so please excuse my ignorance. Any suggestions as to how to approach this would be appreciated.
Edit:
Further reading suggests that I can try to bit bang 3 pins with DigitalWrite, though this would pretty much lock up the controller making it unavailable for feedback loop stuff.
It also seems to be suggested that I use something like a 12-channel 16-bit PWM LED driver, and talk to it over SPI.
Finally, the atmega32u4 seems to have 3 channel 16-bit PWM, though I can't confirm that right now. Here's an answer from SE purporting to have 3 channel 16-bit PWM using register manipulation. This seems to be the most sane option right now.
lionelbrits:
I have a project in which I need to control a small 3 phase motor with something like an Uno, and I from the research I've done I understand that I probably need something like a L6234 to drive the coils. However, here the current to the three phases is controlled by PWM, and I understand that PWM output is 8 bit on the Arduino (16 bits for one pin?) and I need finer control. Is there a straight-forward way that I can write to 3 pins with 16-bit PWM signal? Ideally I would have some room left over to read from an encoder for feedback.
You probably won't need more than 8 bit PWM, motor control is all about feedback loops, so you will need
the accuracy in the sensors, not necessarily the motor drive signal as the feedback can correct this,
especially if the update rate is high enough, as momentum smooths over the variation.
The Arduino Mega has four 16 bit counter timers, and some have 3 PWM pins they control, so you can
generate 16 bit 3-phase PWM using them if you want.
The Uno has only one 16 bit timer, timer1, and this only controls two pins, 9 and 10.
The Mega has these 16 bit timers:
timer1 controls pins 11,12 (and 13 if you use direct register access)
timer3 controls pins 2,3,5
timer4 controls pins 6,7,8
timer5 controls pins 44,45,46