I'm trying to wire a 12v DC motor to a DPDT switch so I can control the spin direction (by inverting the polarity) it uses two digital pins, one of them to set the direction of the motor and another one to actually enable or disable the current flow to the motor. The design I came up is this one:
I'm not sure if the relay is wired correctly to achieve the desired functionality
Best Answer
Unless you want possible excessive contact arcing on your relay I'd put diodes on like below: -
Of course, if you adopt the reasonable approach to deactivate the MOSFET first then you don't need them in ideal circumstances.
Due to stored mechanical energy in the motor, the catch diode on the MOSFET may dump excessive motor energy onto the 12 volt rail and you should have some form of over-voltage prevention scheme here like a big bulk capacitor to soak up excessive energy dumps on the rail or maybe a zener diode or some form of braking resistor. You don't want your 12 volt rail being driven upwards I would have thought.