I am new to Arduino and have only a very basic knowledge of electronics.
I would like to create a mixer for controlling the vibration speed of four electric toothbrushes (each toothbrush is normally operated using a single AAA battery). I will hack the toothbrushes so that audio cables will connect the toothbrushes' motors to Arduino (Uno) via a PCB screw terminal block mounted on a breadboard, and intend to control then Arduino using a MIDI controller.
I found several tutorials on how to control the speed of DC motors with Arduino, and made the attached scheme based on them. The thing is, that they all referred to a single 6V DC motor, so I'm not sure if (1) I got it correctly and it should work, and (2) what the values of R1, R2 and the transistor should be.
I have no technical specs of the motors. I can try to measure it using Arduino and a 10 ohm resistor (I have no ammeter, and the smallest resistor I have is 10 ohm). How accurate will it be?
I thought that if I divide the 5V in series to 4, I could drive each motor with 1.2V, which is about the same as the battery ...
Is there a specific model I should look for? That's basically what I am not sure about .. the examples I've seen use PN2222.
Yes, the speeds are to be controlled independently.
In series isn't going to work, your signals are referenced to ground.
How much current do the motors use? You need a multimeter or to find a datasheet for the
toothbrush (unlikely), or find someone to measure another similar toothbrush.
And is there a way then to divide Arduino's 5V so it will work?
You don't HAVE to use the 1.5V the toothbrushes are designed for, You can use 5V with a PWM duty cycle of 5/1.5=0.3 or 30% (or 255 * .3 = 76 for the Arduino PWM value). But you want to control the speed so you will be varying the PWM value in some range like maybe 40..80).
I will be able to measure the toothbrushes with a multimeter on Friday.
Some questions regarding the suggestions:
If I modulate the PWM in a range like 40..80, should I just connect the transistors so their collectors and emitters are connected in parallel to the 5V and GND and their bases are connected to the corresponding PWM outputs?
I also wonder if there's a way to achieve a better resolution. The PWM are limited to 256 steps. As I said, I intend to use MIDI, which reduces that to 128 steps. But varying the PWM in a range like 40..80 reduces it even further ...
If I use buck regulators, should I connect several in parallel to the 5V and GND? Then, is the circuit the same as in the scheme I attached, connecting the collectors and emitters of the transistors to the corresponding outputs of the buck regulators? And I'm not sure I understood how to determine the step-down ratio. Is it a fixed value (even though it is written that this specific model is "adjustable")?
A good voltage regulator will maintain a constant output voltage over a wide range of input voltages. The module I linked to has a small potentiometer next to the inductor that adjusts the output voltage.
There are several ways to increase the resolution of PWM, for instance by using a 16 bit timer in a 16 bit
PWM mode.
In software you can dither the PWM value between adjacent values at a suitable rate to simulate finer
resolution.
void dither_pwm (byte pwm_pin, unsigned int pwm_in)
{
static unsigned int error = 0 ; // persistent state between calls
pwm_in += error ; // carry over from last time
byte output = pwm_in >> 8 ; // top 8 bits are used as actual PWM
analogWrite (pwm_pin, output) ;
error = pwm_in - (output << 8) ; // carry over remainder for next time
}
Which uses 16 bit resolution for pwm_in, but only uses the top 8 bits to the hardware, but
carryies over the error between calls to make the average output value equal to the accurate
16 bit value divided by 256.