Correct schematic for DC motor contoller

Hi, I want to make this dc motor controller
http://arduino.cc/playground/Main/DCMotorControl

but it says to contact the forum as the schematic is incorrect. Any idea where i can find the correct one thanks

Hi, It's just really oversimplified and assumes that you can get a Double-pole double-throw relay that can be driven directly from Arduino.

Anyone have a pointer to something more realistic??

You could use a relay board like this with two Single-Pole Double-throw contacts, plus the transistor speed control... :
http://arduino-direct.com/sunshop/index.php?l=product_detail&p=171

DISCLAIMER: Mentioned stuff from my own shop...!

No, a schematic with a double pole double throw relay to change direction on a single motor was posted in the last couple of days.
Something like this.

Thanks. I don't need a controller to turn a motor in both directions. Im really looking for one that will turn a motor in one direction but with variable speed. Looked round on the Arduino playground and tutorials, but not sure there's anything simple enough for me, as this is first project. Also reading a schematic is going to be uphill...

See attached.

I like also to wire a 10k ohm resistor between mosfet gate and source terminals. This forces the motor off if for any reason the Arduino is powered off or reset but the motor's voltage source is still on.

Lefty

retrolefty:
I like also to wire a 10k ohm resistor between mosfet gate and source terminals. This forces the motor off if for any reason the Arduino is powered off or reset but the motor's voltage source is still on.

Yes, that's a good thing to do, I usually do it myself too.

thanks that. Strugglling to read the schematic. Is it the 'Arduino PWM pm'? and what is that? Also am i correct in reading 'Logic level power mosfet'?

Once ive got this circuit built (with the additional resistor), do i then use the code from the original motor controller thread?
thnaks in advance.

Sorry for my poor writing, it's 'Arduino PWM pin' meaning an Arduino output pin that supports PWM. You set the power you want by making an analogWrite call to that pin.

'Logic level power mosfet' means a N-channel power mosfet with logic level gate drive (i.e designed for 5v gate drive instead of the usual 10v). I usually use type STP40NF10L but that's rated at 100v 40A (both much more than you need) and there are cheaper ones that will work in this design.

The diode connected in parallel with the motor needs to be rated at the full stall current of the motor.

If you want to control the motor speed using a potentiometer (as in the playground example but in one direction only), there are a couple of things wrong with the schematic. The pot should be wired with one end connected to +5v, the other end connected to ground, and the slider to pin A0. The other thing wrong with it is the position of the diode, but if you're using my schematic then that's already dealt with.

Here is a sketch for controlling the motor from the pot:

const int PotPin = 0;
const int MotorPin = 11;

void setup()
{
  pinMode(MotorPin, OUTPUT);  
}

void loop()
{
  int value = analogRead(PotPin);
  analogWrite(MotorPin, value/4);
}

Thanks, very helpful. Re the diode in parallel, i've no idea what the full current of the motor. I've made a homopolar motor using a number of small neo magnets and a copper coil round an iron bar. The motor works, but it goes far too fast. trying to slow it down with this controller. is the diode something i can just guess at, or do i have to figure out the current of the motor?

If you have a multimeter that can read a couple of amps or so, you can put it in series with the motor to find the current it takes. The worst case is the stall current, i.e. the current when the motor is prevented from rotating.

Alternatively, measure the resistance of the motor with multimeter. Divide that resistance into the voltage you want to run the motor from to get the stall current.

If the current is not more than 1A, you can use a 1N400x diode where x is any digit from 1 to 7. Actually, these diodes are probably good for 2A of motor current, because they are rated at 3A pulsed and they only have to take short pulses in this application.

If the motor current is higher, then go for a higher-rated diode as appropriate.

Thanks, this is proving far tougher than i’d imagined. I think its the different suggestions and alterations that are throwing me off, not to mention novice status and general incompetence. Anyway a few questions re the schematic:

Where does the ‘motor supply +ve’ get connected to? Is it the 5V on the arduino?

Where does the 'motor supply - ve connect? It’s not the ground, so where?

Im having a hard time picturing how the diode that bypasses the motor actually is wired on the breadboard.

Also true for the Mosfet. If the mosfet is theis the arrow facing left, then what is the gap and next white line? a switch? (or is that all the mosfet). The resistor comes after than, and then that gets connectd to the PWM pin.

The diode that you show bypassing the motor, how exactly does one wire that?

I will try to put an effort together and post it.

thanks again

Motor+ connect to power supply, the one that feeds the power jack, generally not a good idea to supply from 5V regulated power.
Makes regulator run hot, can starve the ATmega of current & cause resets also.

Motor- in this case is Arduino ground, as you are running 1 direction only.

Diode needs to be wired across the motor, as close to the motor as you can.

The Mosfet is all the lines.

How you connect the diode is up to you & your evolving assembly skills :slight_smile:

ebarker2:
Where does the 'motor supply +ve' get connected to? Is it the 5V on the arduino?

Where does the 'motor supply - ve connect? It's not the ground, so where?

The Arduino 5v line probably can't supply enough current for the motor, so I assumed you would be using an external supply for the motor, such as a battery or wall wart (possibly the same supply that you use to power the Arduino through the barrel jack or Vin pin). That's where the motor supply + and - come from.

ebarker2:
If the mosfet is theis the arrow facing left, then what is the gap and next white line? a switch? (or is that all the mosfet).

It's all the mosfet.

ebarker2:
The diode that you show bypassing the motor, how exactly does one wire that?

In parallel with the motor, with the stripe on the diode on the end that is connected to the +ve supply.

Im going to tr'y this tomorrow. I couldn't find this particular mosfet, so bought another, 100v 30 amp one. Where do I find the sketch for the arduino, or does the one from the original thread work? thanks

I don't need a controller to turn a motor in both directions. Im really looking for one that will turn a motor in one direction but with variable speed. Looked round on the Arduino playground and tutorials, but not sure there's anything simple enough for me, as this is first project. Also reading a schematic is going to be uphill...

The original sketch can be made to work.

The Arduino 5v line probably can't supply enough current for the motor

Make that "The Arduino 5v line defnitely can't supply enough current for the motor and trying to do so may damage the Arduino board".

check this, if it helps so good, if not then sorry :slight_smile:
if u want to increase and decrease speed of your 12V DC motor in one direction, u should have 12V DC supply and any of the 5 Volt NPN transistor..
so u can do it in 2 ways, according to your needs.. if u want to control it by yourself at anytime so u can use potentiometer connected to analog pin 0 i-e (A0), otherwise if u want to control it according to time or some sensor so instead of potentiometer u may give input according to that, so after this connect PWM pin 10 to NPN transistor base and connect motor and 12V battery in series in between collector and emitter of transistor..
if u r new, so in program i have also explained everything..

/*
  Motor Speed Controller
  First Declare an integer variable "potentiometer" for 
saving the input value of potentiometer.
  The speed of the Motor will depends on the value obtained by analogRead(). */
intsensorPin   = A0;        // select the input pin for the potentiometer
intmotorPin    = 10;     // select the pin for the Motor
intsensorValue =  0; // variable to store the value coming from the sensor
void setup() 
{
pinMode(motorPin, OUTPUT);  // declare the motorPin as an OUTPUT
}
void loop() 
{
     // Range of Analog Value(Potentiometer) is in b/w 
  // "0" & "1023" as we have 10 bit ADC in Arduino.
sensorValue = analogRead(sensorPin);
     // PWM is 8-bit so we can write from 0 to 255 not from 0 to 1023.
  // So using map function we will write sensorValue on output.
int mapped = map(sensorValue, 0 , 1023 , 0 , 255);
analogWrite(motorPin, mapped);  }

ebarker2:
Im going to tr'y this tomorrow. I couldn't find this particular mosfet, so bought another, 100v 30 amp one.

Just make sure it's a logic level mosfet, not an ordinary one - especially if your motor may take more than 1A.