Tips for +/- switching for motor forward and reverse

I am trying to control a fairly high amp draw 12v motor. I am guessing it will draw 15amps but I am shooting for 20amps to be safe. I need to be able to spin the motor forward and backward.

This will be my first project outside of the starter kit. I apologize in advance.

I am looking at a basic set up like THIS but insted of a controlling a small motor or a light bulb I will have a 12v automotive relay like THIS to provide the power to the motor. What I am having trouble figuring out is how to swap the polarity on the motor so that it will spin both directions.

I have breifly started researching H Bridges. I am not sure I understand them, but is that the rabbit hole I should be going down for this?

I have breifly started researching H Bridges. I am not sure I understand them, but is that the rabbit hole I should be going down for this?

Yes. You need an H-Bridge or a DPDT relay. See [u]this thread[/u].

The "catch" is, unless you also have a negative voltage source, you have to switch both motor connections.... You can't have one of the motor wires "permanently" connected to ground or to the power source like you would with a normal on/off switch or a normal speed control.

If you also like to control speed at some time in the (near) future, you need to go for H bridges, which are the heart of motor shields.

If you want to always have your motors run at full speed, then you could use relays.
But not those automotive single pole ones.
Use dual pole double throw relays instead (DPDT).
This is the contact configuration:

You need 2 of these relays, one for each direction.
A single one would have the motor always running without allowing it to come to a stop after running in one direction (not good).
The motor gets connected to the 4 common pins.
One relay gets the + to the upper contact labelled NO, the - to the lower NO.
The other relay gets the + and - connected upside down, but still to the NO contacts.
Be sure to always switch just one relay, or else you will create a full short and blow up something.

I agree that the H bridge is a much better way to do this.

MAS3:
You need 2 of these relays, one for each direction.

Better to use one relay to change direction (i.e. polarity) and one relay for on/off. That avoids the risk of shorting the power supply. However it's probably advisable to switch off motor and allow time for it to come to a stop before reversing polarity.

Thanks for the tips. I am not familiar with DPDT but I will look it up.

This is going to be a pretty simple control. The motor will spin at full speed in the morning and then spin the other way in the evening.

MAS3, With that info do I still need two DPDT relays or can I make it work with just one? and a simple 12v automotive relay.

From what I know so far I think I can make this work with:

TIP122 (X2)
DPDT relay
SPDT relay
Does that sound right?

See Reply#6 of this post.

I used these mosfets: (60V/30A)

P-Channel
N-channel

I used these HEATSINKS (40 cents/EA, USD/TO220/ALUMINUM WITH FINS)

I am running it right now using a 9V motor and this code : (simple test program ramps up motor and changes direction and repeats)

int motorPin1 = 9;
int motorPin2 = 3;
int motorPin3 = 5;
int motorPin4 = 6;
int dlyTime = 2000;

void setup() 
{
  
  pinMode(potpin,INPUT);
 

  pinMode(motorPin1, OUTPUT);
  pinMode(motorPin2, OUTPUT);
  pinMode(motorPin3, OUTPUT);
  pinMode(motorPin4, OUTPUT);
 
}

void loop() 

{
  // put your main code here, to run repeatedly:

analogWrite(motorPin1,75);
delay(dlyTime);
analogWrite(motorPin1,150);
delay(dlyTime);
analogWrite(motorPin1,250);
delay(dlyTime);
analogWrite(motorPin1,250);
delay(dlyTime);
digitalWrite(motorPin1, LOW);
delay(dlyTime);
//===========================
analogWrite(motorPin2,75);
delay(dlyTime);
analogWrite(motorPin2,150);
delay(dlyTime);
analogWrite(motorPin2,250);
delay(dlyTime);
analogWrite(motorPin2,250);
delay(dlyTime);
digitalWrite(motorPin2, LOW);
delay(dlyTime);
}

The TC4427 prevents shoot- through because if both inputs sre HIGH, BOTH outputs sre LOW.

MAS3:
Use dual pole double throw relays instead (DPDT).
This is the contact configuration:

You need 2 of these relays, one for each direction.
...
Be sure to always switch just one relay, or else you will create a full short and blow up something.

Archibald:
Better to use one relay to change direction (i.e. polarity) and one relay for on/off. That avoids the risk of shorting the power supply.

I don't "get" all this confusion about using unnecessarily complex DPDT relays or "shorting the power supply".

To provide reversing, you use two SPDT relays and there is no risk of shorting the power supply.


This arrangement (equivalent to an H-bridge, but with no risk of "shoot-through") causes "dynamic breaking". You might need an extra SPST relay in series with the motor if this was not desirable.

I don't "get" all this confusion about using unnecessarily complex DPDT relays or "shorting the power supply".

There is no valid justification for concern about "shorting the power supply" with a DPDT. I don't recall your justification for two SPST relays instead of a single DPDT relay since the last post about this topic a year ago when we went through the same drill. The addition of an ON/OFF relay is probably recommended. As I recall you had some reason for separate relays but I don't remember what it was.

raschemmel:
As I recall you had some reason for separate relays but I don't remember what it was.

I don't either for a year ago, but generally, more robust.

Also, generally more convenient - one for forward, one for reverse, enable only one to operate. Actuating both causes no particular problem.

Dynamic braking can be defeated by adding two diodes in series with either both NO or both NC contacts, resulting in four "modes".

Maybe that was the reason: dynamic braking feature possible when using separate
relays. (ability to short both motor terminals to either GND or Vcc)

If it was a robot car you could accelerate at full speed toward a wall and then skid to a stop at the last second.

Alright now you guys might be giving me to many options. It looks like the mosfets will be the cheapest route. Are there any draw backs to going that route? That also give me motor speed control options should I ever need/want it correct? So if I went that route I would need 5 mosfets mosfets total, correct?

raschemmel:

I may be missing it in the other thread but what resistors are you using for that hbridge? Mine will be running off a 12v battery if that makes a difference.

There is no valid justification for concern about "shorting the power supply" with a DPDT. I don't recall your justification for two SPST relays instead of a single DPDT relay since the last post about this topic a year ago when we went through the same drill. The addition of an ON/OFF relay is probably recommended. As I recall you had some reason for separate relays but I don't remember what it was.
[/quote]

Actually, when the relays are controlled by two Arduino pins, just actuating one relay effectively turns the motor OFF. Either relay turned on will effectively turn the motor OFF by making the voltage on each side identical. So,two relays will give you reversing directions as well as an off position.

Also works well with Peltier devices.

Paul

That's it ! it was Paul_B who said (about a year ago) that two relays (as shown) makes it unnecessary to add another relay for ON/OFF. In addition it allows for dynamic braking.

So if I went that route I would need 5 mosfets mosfets total, correct?

Only 4 mosfets. On off is controlled by the uP. If using the TC4427, both inputs LOW or
both inputs HIGH results in both outputs LOW. (NO POWER TO MOTOR) , making an ON/OFF mosfet unnecessary.

I may be missing it in the other thread but what resistors are you using for that hbridge? Mine will be running off a 12v battery if that makes a difference.

When you use PWM, resistors aren't necessary. You can control the current with the duty cycle. Besides, your motor is a 12V /300W dc motor and you are using a 12V battery so there's no need for dropping resistors. I didn't use them in the other thread because that was a 12V stepper motor running off a 12V supply. (there is no PWM when driving a stepper motor. That doesn't mean you couldn't use PWM to control the torque but it is not usually done, although there is nothing stopping you from doing that.)

I am seeing several different part #s for the tc4427:

TC4427COA
TC4427EOA
TC4427CPA
TC4427EUA

Which one do I need for my application?It looks like the min difference is the temperature rating.

TC4427CPA

You must realize that "TC442X" denotes the logic type

TC4426 Inverting
TC4427-Non-Inverting
TC4428 Complimentary

and the "XXX" at the end designates the PACKAGE TYPE, TEMPERATURE RATING, ETC..

I am using a breadboard so I want the DIP (CPA)
C = 0 deg C to 70 deg C range
PA = Plastic DIP, 300mil body, 8-lead

see page 17 (see Examples at right side of that page for logic type, left side for suffix glossary)
datasheet

Incidently, make SURE you look at the datasheet for the Power Pins. The TC4427 has very unusual pin numbers for Vcc & GND. After you have the Vcc (Mosfet Power Supply voltage) connected to Vcc, test the TC4427 by applying logic (TTL 5v signals) HIGH & LOW to the input pins. You will only get HIGH outputs
when one input is LOW and the other is HIGH. All other logic input combinations yield LOW on BOTH outputs.

Note: In (Reply#6) of the post I linked about the H-bridge, there is a note that the TC4428 was not used because it was the wrong part and that the correct part was the TC4427. By looking at the schematic in the other post and reading the datasheet, it should be evident WHY the TC4428 was the wrong part. In addition there is the implication that the circuit worked with the TC4427 which confirms that is the correct part.

Also: if you plan to use the heatsinks I linked, the tapped screw thread is metric, (M3)

If you are in the USA you can get an even better heatsink at RadioiShack that has a 4-40 screw hole, which I
think is also tapped. You can see from the photo that the total finned heatsink area iis almost double the area of the futurlec heatsinks, the height is twice the height and the fin depth is twice the depth. In short, while the futurlec heatsinks are $ 0.40 USD, and the Radioshack heatsink is basically $2.50, the
Radioshack heatsink can easily dissipate three times the heat of the futurlec heatsinks. This becomes important if you plan to draw more than 10A per mosfet. Keep in mind, in an H-bridge, there are always 2 mosfets in SERIES so they will always dissipate the same amount of heat.

I am guessing it will draw 15amps but I am shooting for 20amps to be safe. I need to be able to spin the motor forward and backward.

Since you are shooting for HALF the rating of the mosfets I linked, they may get warm but not too hot. You can try the cheap smaller heatsinks first and see how hot they get or you can play it safe and use beefier heatsinks like the Radioshack type. It is much better to have a thermocouple for test purposes (I have one of these and display the temp on an I2C LCD). If you had something to measure the heatsink temp you could compare the two heatsinks by making a simple one mosfet test setup and just apply 5Vdc to the gate of the mosfet with the motor connected to 12V and the Drain of the mosfet and the Mosfet Source connected to GND. You can then turn it ON with a logic (5V) HIGH and OFF with a logic LOW, if you used the mosfets I linked.

Thanks for all your help with this. I have all the parts on the way. I will report back when it all arrives. Until then I will study the datasheets and try to draw up a diagram. I went with the cheaper heatsinks. I don't anticipate the motor running for more than 30 seconds so I don't think it will be an issue.

I suggest you test thecTC4427s independently to verify they output the motor supply voltage ( make sure you connect Vdd to 12V and not 5V.)
Also, test your mosfets individually using your .motor with a single polarity., so you know where you stand before you evdn build the circuit.

Do you mean I need to confirm all components are working before I put it all together?

Do you mean I need to confirm all components are working before I put it all together?

No, that is not what I meant. What I meant was that if you do not have electronics experience, you need to be systematic in your build. I have 30 + years working in the electronics field and when I breadboard a prototype circuit at work, I never throw everything together and flip the switch. That's just plain stupid. I would only do that if the engineer told me he needed the circuit ASAP and don't waste any time with the usual preliminary checks. What I mean is that if you test the mosfets, one by one, all that requires is a simple test setup and 2 seconds to plug in each mosfet , one by one , turn on the power and then turn off the power and test the next one. But because it is an H-bridge, you need two separate test setups; one for the N-channel mosfets and one for the P-channel mosfets. In both cases the test setup only takes 5 minutes to build and 2 to 5 seconds per device to test them. If you have never worked with these , you should not even be building this circuit in the first place but if you have made up your mind to do it then you need some training. You first need to learn how to test an N-channel mosfet, and then how to test a P-channel mosfet. After that is done, you need to test the TC4427s so you know they are working BEFORE you combine them with the rest of the circuit.
I did every one of these tests for the circuit I linked (that you are now planning to build)
I tested all the mosfets (in my case 4 N-channel and 4 P channel because I had 2 H-bridges to drive the stepper motor. I tested both TC4427s. The entire testing took less than an hour. Your testing should take half that time because you are only building one h-bridge.

WHY DO WE DO THIS ? It's very simple. If you have tested each component individually before building the circuit, you know all your components ARE THE RIGHT COMPONENTS (and they didn't ship you the wrong part by mistake) AND you know they are GOOD components. Most importantly, if the final circuit doesn't work, you KNOW it is because YOU MISWIRED IT somewhere. (missing a wire or something connected incorrectly). When I am building a circuit at work, sometimes the engineer will come by and ask "How's it going ?" and I can tell him:
"All the driver chips tested ok, all the mosfets tested ok, and I'm assembling the final circuit now..."
This tells the engineer I am systematic, methodical, and thorough which is what he wants .
That's how we roll...
Do you really want to put everything together and turn on the power and see smoke rising from your breadboard and find out you fried everything because you didn't know what you were doing ?

If you have previous experience troubleshooting H-bridge circuits, then go ahead and build the circuit and test everything at one time. If you are simply too lazy to spend 30 minutes to test the components before building the circuit then I'm wasting my time. In my mind , there is no excuse or reason you can offer that would exempt you from the need to test the components short of saying you have done this a dozen times and are certain you won't miswire it.