I need help with controlling the speed of a DC motor. I've already got th direction figured out using ARDX's examples using this schema :
I was wondering if I could control speed of the motor using another transistor with PWM on an arduino pin. Thing is, I'm still very noob in hardware since I'm a programmer and I don't know how I would wire it up.
To control both direction and speed of a motor takes at least four transistors in a H-bridge configuration. Search around here and the Arduino playground site for H-drive", should be lots of examples. There are pre-built and kit motor driver shields that can also perform that function.
He could stick another NPN between the ground and the connection junction of the NC/NO contacts; the collector going to the contacts, the emitter to ground, bias resistor on the base (then connected to the Arduino), and a flyback/snubber diode across the collector/emitter junction (I think).
He could stick another NPN between the ground and the connection junction of the NC/NO contacts;
I'm not so sure, the voltage polarity switches with the relay switching. If you can draw it using only two transistors, one for direction and one to PWM speed modulate it, then I will bow to your skills.
I think the idea of cr0sh would work as outlined. The PWM transistor will switch the relay ground connections and the existing transisitor will determine which motor terminal gets connected to ground/power.
This would also work as an Arduino controlled on/off switch which is missing from the current design. An H-bridge would obvoisuly be preferred if fast direction switching is needed (as the mechanical relay will wear), but for many applications it may be suifficient (e.g. manually operated doors).
The PWM transistor will switch the relay ground connections and the existing transisitor will determine which motor terminal gets connected to ground/power.
I think that might be problematic. Applying a PWM signal to the direction relay coilsl ground connection would have the effect of modulating the direction relay coil when the motor is turning in one direction. That may cause erratic drop out of the relay at slower speeds?
There is a problem here that flyback diodes alone cannot solve - the relay is a mechanical switch so it has significant dead time (open circuit). Thus there will be high voltage transients and arcing - since the polarity switches you can't just put a diode across the motor to prevent this.
An RC snubber across the motor is probably needed, and you'll still need a flyback diode the other side of the relay to protect the PWM transistor.
The RC values depend on the motor characteristics - and not in an easy to calculate way I fear. The cap has to absorb the magnetic energy without going to too high a voltage and the R has to dampen the oscillations of what would otherwise be a resonant LC circuit.
Applying a PWM signal to the direction relay coilsl ...
I'm not sure I follow on this remark. He would not PWM the coil, but the supply ground side towards the DPDT ground terminals. Is it not so that the coil supply is completely separate from the main DPDT supply - or did I miss something?