[SOLVED] Bi-directional motor control with two mosfets?

Hi all. This is my first topic. I subscribed because I gave up searching for the answer and am in the need to ask this question here, hoping I will get some enlightenment.

It’s been 2 weeks I am playing with motors controlled by Arduino.

I went through most (not all of course) of tutorials, looking at pictures and obvious reading lots of topics in this forum and also in others.

So far I built and plaid with an H bridge and also the DPDT relay with TIP transistors for Direction and Enable pins. There is also a topic where is explained that with low power motors one can directly drive from ARduino with 2 PWM pins. Did that too.

Thing is I envisioned a schematics (beginner in electronics) and I wonder if this could work. The issue is I am using a Pro Mini trying to control usual cheap RC car motors and trying to figure out what would be the simplest way. (By now the DPDT relay seems ok).

The other day I’ve seen the schematics for powering a one direction motor with a mosfet and I was wondering if it would be possible to switch direction with two mosfets like in the example with direct control of low power motors, setting one PWM pin to Low and the other one being pulsed and the other way around to change direction.

I am telling this whole story for maybe you can discover mistakes or things that are not correctly said.

So I attach the schematics I’ve made and I would like to knoe if this was possible.

G1 and G2 would be input PWM pins from Arduino, M1 and M2 the motor’s connections.

Thanks in advance.

No, that won't work. Among other problems, there is no ground connection.
H-bridges are the way to go, so study current flow diagrams like this:

Thanks for your fast response jremington.
My doubt is when one PWM pin is Low doesn't this mean is grounded?

As far as I understand that would mean that between one pin, say G1, and the other one G2 that is pulsing, would appear potential difference then the motor would have ground and positive pulses. Is this wrong? Or is it like this?

when one PWM pin is Low doesn't this mean is grounded?

Yes, but the pin is not allowed to conduct more than about 20 mA current. So, it does not normally count as circuit ground or battery ground.

OP"s image...

Are you expecting motor current to flow through R3 and R4 through the Arduino pin to ground?

For a similar idea but using LEDs which can be driven directly from an Arduino pin, look up "Charlieplexing".

I'm quite sure it is possible to build an H-bridge that can work on a single pin for direction AND speed control.

I've never built the complete circuit that I dreamt up, but all the parts work fine when tested. It works as an Arduino pin is tri-state. So high for one direction, low for the other direction, and high impedance for off. It uses a number of MOSFETs and BJT transistors. Shoot-through is prevented by slowing the on switching of the MOSFET, off is achieved by connecting the bases of a PNP and a NPN transistor which makes them switch on each other, and in turn off the MOSFETs.

Regular PWM doesn't work for this: the pin would have to switch between H/Z resp. L/Z instead of H/L.

It's even possible to make it work with a motor voltage higher than the Arduino voltage but that makes the circuit quite complex. The slowish switching of the MOSFETs also means no high currents as losses will be too high. As I don't think there's much of a practical use for it I left it at that. Nonetheless a fun thing to figure out.

For bidirectional control you need either:

4 switches, single supply, single motor winding

2 switches and a bipolar supply, with centre-ground going to one side of the motor winding

2 switches and dual motor windings (or a centre tapped winding).

Thanks all for your answers.

I could test it by myself but I said to myself that before toasting an Arduino board(which is very dear to me) I better first ask somebody that knows and understands much more than me on this matter.

In my mind when you connect the common ground of two power sources (motor and circuitry) that was as the ground is only as reference point of zero and the current gets consumed in each circuit, the motor takes Amps and the electronics mAmps. I don’t know how the currents manage to stay separated tough they have common ground if not only for what’s in the middle between each positive and ground.

So I thought that a Low pin can serve for this common ground function. Apparently not.

Well, given this stage I think I would choose the DPDT realy version because it can drive as much as the relay stands and I only need one PWM pin if I am not mistaking.

@MorganS, yes that is what I thought first but then maybe R3 and R4 should be a bigger value. And about charlieplexing, if they were diodes instead of resistors (or both) with cathode placed on the pin wouldn’t this work then?

I went through and made the version with diodes. It looks better and it has a ground but the same question remains.

Thanks again.

PWM 2 pins mosfet FWD BKD sch V2.jpg

Can't possibly work. The diodes D3/D4 are short-circuits to ground, they will be forward biased always,
when either MOSFET is on it will short the V+ to ground via a diode and burn up the diode (1N4148's
are signal diodes, not power devices).

Diodes D5 and D6 are serving no useful purpose.

Diodes D1 and D2 are redudant, power MOSFETs all contain body diodes (as you can see from the symbols).

With a two wire motor and a single supply, 4 switching devices are required, as I stated.


D5 D6 were for preventing feedback to pins G1 G2... :smiley:

All the rest you're so right. I give up.

Thanks all.

I’m back… and very sad.

I had to come back for a few reasons, it’s about the same project and is related to this thread. That’s why I followed here.

For more that I tried to avoid burning an Arduino board and asked here if the schematics works, well, (not well) I managed to burn a board because I needed 12v dc in the project and I said I could power the Arduino also from that 12V source.

I don’t understand if there are more types of GND pins then just… GND. I attach a picture to explain visually what happened.

But in words, on the Pro Mini I worked with, the FTDI connection works on one specific GND pin on the header and not on the other.

I did my tests at 7.2Vdc powering the Arduino on Raw pin (+dc) and first close GND pin on the top header. Everything went ok.

When I put 12V dc connected in the same way, the board burnt (smoked somewhere around the capacitors zone) even if it’s a 5V version and everywhere it tells it can be powered at 12V. Actually there were 11.5V.

So the question is if there are different types of GND pins connected like in two separated threads?

I didn’t test another board in another configuration.

(Sorry if I had to open another thread, just let me know or do what is needed.)

Thank you.

All grounds are connected to each other (at least, are supposed to).

Cheap clones may have skimped on the capacitors and used ones that are just 12V rated instead of the minimum 16V you'd need for a 12V supply. A minor instability on your power supply, or a cap that's just barely reaching its rating, and the smoke comes out.

Also the voltage regulator is placed close to the capacitors!
If you draw any kind of current from the 5V side apart from the chips on the board, you could have easily overloaded the regulator?

Regulators should have protection against that (they normally simply switch off when overheating).

And the same advice as always.

It is safest to consider the internal regulator on the Arduino UNO, Nano, Pro Mini, Leonardo as not suitable for powering anything other then the microprocessor chip itself given also that it is not providing substantial current on a number of outputs at once.

The obsolete tutorials on the Arduino site and others imply that the largely ornamental “barrel jack” and “Vin” connections to the on-board regulator imply that this is a usable source of 5 V power. This is absolutely not the case. It is essentially only for demonstration use of the bare board back in the very beginning of the Arduino project when “9V” power packs were common and this was a practical way to power a lone Arduino board for initial demonstration purposes. And even then it was limited because an unloaded 9 V transformer-rectifier-capacitor supply would generally provide over 12 V which the regulator could barely handle.

Some “clones” such as the “RoboRed” and more sophisticated Arduinos do incorporate an actually functional switchmode regulator but it should simply be ignored on the older designs. :grinning:

Nowadays, 5 V regulated switchmode packs are arguably the most readily available in the form of “Phone chargers” and switchmode “buck” regulators are cheap on eBay so these can be fed into the USB connector or 5 V pin to provide adequate power for all applications. Unfortunately, many tutorials or “instructables” are seriously outdated or misleading and have not been updated to reflect the contemporary situation.

I guess the Arduino is old enough that nobody had fourteen old phone chargers with USB connectors around the house to supply power back then.

It's also a learning environment. The 1A regulator on the UNO can actually do 1A under very specific conditions. Teaching how to find and read datasheets is part of the mission of Arduino. It's much better to learn by turning a $30 Arduino into smoke than a $130k device that your employer paid for.

The 1A regulator on the UNO can actually do 1A under very specific conditions.

One drip per second of liquid nitrogen?

That, combined with lowering the input voltage to about 6.5V, as in 5V+ the minimum dropout at 1A output current. No liquid nitrogen can compensate for 12V input.

I understand that I have to be careful when playing with the 12V that is at the top limit of these boards.

At Raw pin I was powering only the electronics on the Arduino board and from 5V pin the HC-12 receiver module.
Motors were powered from a different 4V battery as before.
The 12V battery source was intended to be split for electronics and anything else that might need 12V but nothing else was not connected at that moment.

I tried to identify what smoked out but was not able to. In the moment I've seen the smoke it was coming from the regulator zone, but no precise component.

Could the processor be still alive? I saved it for maybe in the future I could place it on a spread board to use it. I did a test to upload some sketches but the upload was hanging.

I was wondering if it was I doing something wrong or something else.

So, in this case I should take down the 12V to around 5V to power the Arduino to make sure no smoke will be seen again. Right?

Or another option would be to change the capacitor to a 16V one, could do the trick?

What could be the simplest path? (I need 12V from a battery pack and only one for this project and I will definitely have to take down 5V for motors. Should I have different regulator modules for modules and Arduino? I expect a maximum 3A load on turn motor because is the stock "servo" that works on torque (very stupid).
Maybe I am kind of pushing the limits with what I am trying to do... I don't know.

Thanks so much. Learned lesson.

The processor may or may not be working, if it's a capacitor that burned very likely it still works. Try powering it over USB and see what happens.

Without knowing exactly which component broke I'd not trust the board any more, and just toss it in the bin and grab another. They're too cheap to spend much time on.