Go Down

Topic: [SOLVED] Bi-directional motor control with two mosfets? (Read 7851 times) previous topic - next topic

zeeproduction

Jan 09, 2019, 11:28 pm Last Edit: Feb 15, 2019, 11:29 am by zeeproduction
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.

jremington

#1
Jan 09, 2019, 11:49 pm Last Edit: Jan 09, 2019, 11:57 pm by jremington
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:


zeeproduction

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?

jremington

#3
Jan 10, 2019, 01:57 am Last Edit: Jan 10, 2019, 01:57 am by jremington
Quote
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.

MorganS

#4
Jan 10, 2019, 12:57 pm Last Edit: Jan 10, 2019, 08:34 pm by Coding Badly
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".
"The problem is in the code you didn't post."

wvmarle

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.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

MarkT

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).
[ I DO NOT respond to personal messages, I WILL delete them unread, use the forum please ]

zeeproduction

#7
Jan 10, 2019, 11:06 pm Last Edit: Jan 10, 2019, 11:34 pm by zeeproduction
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.

MarkT

#8
Jan 11, 2019, 02:23 am Last Edit: Jan 11, 2019, 02:24 am by MarkT
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.
[ I DO NOT respond to personal messages, I WILL delete them unread, use the forum please ]

zeeproduction

@MarkT

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

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

Thanks all.

zeeproduction

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.

wvmarle

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.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

GeronimoDK

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?

wvmarle

Regulators should have protection against that (they normally simply switch off when overheating).
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

Paul__B

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.  :smiley-lol:

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.

Go Up