Very simple motor control

I am a software guy who easily gets over his head in circuits. When it comes to controlling motors, I like the ESC because I understand how to use it but it adds a lot of cost. I look into H bridges and most seem overly complicated. This little circuit seems simple anough to understand and implement:

http://ruggedcircuits.com/html/circuit__7.html

So what's the downside? This is not a hypothetical question. I bought a boat on closeout that should be here tomorrow and it is that "middle grade" of RC - it has an all in one receiver driver board, but has "real" 380 motors, decent enough prop linkage and enough volume to do some USV testing. Possible ways to drive it are to figure out where to tap in to the existing board, get one of the dirt cheap import ESCs and hope it doesn't catch fire or make a circuit to run it. I am not planning on running it at high speed, but more than slow trolling.

I ordered a couple of these:

http://www.jkdevices.com/components-mosfet/logic-level-mosfet-fdp8878

just as an afterthought while I was ordering a 1280 MiniMega, which you may still see on special there. Did I waste $2? Won't be the first time...

nope

The thing called “board” in your schematic is a microcontroller, not a rc receiver. The micro controller can output a PWM signal of any frequency and duty cycle. This is what controls the speed of the motor. The RC receiver outputs little PWM pulses that a servo can read and “translate” whereas a regular motor can not. In terms of the MOSFETS. These can be some tricky things to work with. 

 

Are you planning on having a

Are you planning on having a microcontroller on-board to drive the MOSFET? As far as my Google-fu can help me the ‘380’ motors you’re referring to are brushed DC, so I’m going to roll with the assumption that they are, and that there’s going to be a micro nearby to control the motor driver, for the rest of this post…

Well, you won’t have a BEC included, although it’s not like you can’t just install a discrete regulator if you in fact need one. Apart from that the ESC does SFA (another nice abbrv. for ya) when controlling a brushed motor.

Are you just driving the prop motor forward all the time? If so, the fan controller circuit you posted is totally fine. The Vgs (Gate to Source Threshold Voltage) required to turn on the MOSFETs you bought is only 2.5V at most, so as long as your 1280 is applying at least that voltage to the gate of the MOSFET through the gate resistor the MOSFET will turn on.
Instead of varying the pulse width from 1ms to 2ms for the full speed range like you would for a servo-style ESC, you’ll be more likely to work directly with the duty cycle of your PWM output. Pick a nice frequency for the PWM generator (the optimum varies with motor and driver attributes, I like to start off high and work my way down), set the duty cycle to maybe 50% and start adjusting the PWM frequency until you get the motor running quietly and efficiently .A simple tachometer comes in handy for tuning, but you can do it by eye/ear too.
Once the PWM frequency is tuned, you just have to vary the PWM duty cycle to control the speed… 0% for 0% power, 100% for 100% power. Too easy.
You may need to limit the max PWM duty cycle if your motor is too power hungry for your batteries/MOSFET… or just get more/bigger batteries/MOSFETs.

If you want to run the motor forwards and backwards you’ll need at least 4 MOSFETs in the classic H-Bridge config. Either that or use a relay/etc to flip the motor contacts and reverse polarity. I’ll go into more detail on those options if you actually need them.

Lastly the fan circuit shows a discrete diode across the motor terminals, plus another ‘body diode’ which is incorporated in the MOSFET (your MOSFET has one too). I’ve often just made use of the body diode to protect the MOSFET, but with a bigger, noisier motor the discrete diode would not be a bad idea. As you’re already aware, caps will help if you find the circuit too noisy for other components.

Yes, I know that part of it

Sorry; I didn’t explain well. I am using ESCs and steering servos on a couple of bots right now and I know about generating PWM, though if I said I knew “all about it” I would be lying. I have tinkered with an H bridge motor driver and it died and from following up and looking at alternatives, it seems like H bridges can be tricky to get right. So the Mosfet idea seems appealing. The board will likely be an Arduino Pro Mini, though I might use the MiniMega I just ordered from JK devices. Kinda depends on what else I am tinkering with. I am working on some projects that are funded and ESCs are a no brainer. Others are just hobby/learning and I don’t want to spend too much. I have been using xBees and BlueTooth to do remote control and GPS driven autonomous control. I also have some Nordic modules I want to experiment with.

I used to do firmware years ago and have been over in the SQL and Windows programming world for a while. I got dragged back into low level helping a friend with a side project and remembered how much I enjoyed it. So now I am immersed in the side project, which has had major scope creep and I am finding this a great hobby as well. I have a decent AGV put together and now I am working on a personal USV. The side project is centered around a very cool USV that I can’t say much about due to NDA. It uses ESCs that cost more than my whole hobby budget. 

First reply was to CTC

yours came in while I was typing. I was way too low on details, though maybe not since you answered with a qualified yes. I don’t care about backing up. 

I have a brushed ESC on my AGV, so I have some experience with that end of things. I got a decent deal on an old chassis with motor/ESC to get that. it was not an educated conscious decision, just good luck.

BEC

Forgot to answer that part…

The boat is a 7.2v and will feed VIN nicely for the uC boards I am considering. Since you mentioned my cap experience, you know that BECs have lost a little of their luster from my POV…

Sounds like you’re on the

Sounds like you’re on the right track then.

When your boat turns up I suggest you grab a multimeter and blast the motor with a fully charged battery - see how much you can expect the motor to draw when running freely. Then disconnect the motor and measure the minimum winding resistance with your multi, that way you can also calc the worst-case stall current draw.
From there you can work out the max. heat dissipation that the MOSFET will be taxed with, max. drain on the batteries, etc etc.

I don’t know how to measure the current draw

I tried to think of a way to phrase that without sounding like an idiot, but well, yeah…

I use my meter to check voltage, continuity and resistance (meaning to double check and often correct my band reading to get the right resistor; nothing fancy). That gets you pretty far these days, but I think I just stepped off the end of the pier and would appreciate some swimming instructions…

First off, has your meter

First off, has your meter got a current option?
You’ll probably want to dial it up to the max. in this case, assuming you have different current metering range options on there. All you have to do is throw the meter into the circuit in series with the current loop you want to measure. Note that this is different to measuring voltage or resistance, where the leads of the meter are in parallel with the target. If you only have two leads and they’re fixed it’s as easy as that. If your meter has several leads, or several ports for the leads, you may have to change them around for current metering mode. Hopefully your meter has a manual, if not the at worst you can post a photo and we’ll decipher it.
To measure the motor current you’ll only have one loop, so the setup is easy: battery terminal -> motor terminal, other motor terminal -> meter lead, other meter lead -> other battery terminal.
Which part goes in which place, and what polarity you add it in, do not matter in this example. Current from the battery flows through the motor, and that same current flows through the meter, so the meter will read the same current as what the motor is drawing from the battery. You might get a negative current reading but of course here we just need to know the magnitude.

If you don’t have a current-capable meter you can slap a high-power, low-resistance resistor (sometimes known as a ‘shunt’ for these applications) in series with the motor. By reading the voltage across the resistor with your meter, can can calc the current through it, and therefore through the motor, since you know what the resistance is ahead of time: V= IR therefore I = V/R.

Your wish:I am

Your wish:

I am guessing/hoping it is that big range on the bottom right of the picture...

Your DCA (DC Ammeter)

Your DCA (DC Ammeter) setting only covers 200μA - 200mA, but you’ve also got a 10A setting down the bottom-left there which might be enough. According to the legend on the lead ports, you need to move the red/positive lead into the top spot to use the 10A DC ammeter setting.

Just in case you’ll be drawing more than the rated 10A it’d be best to measure the winding resistance and estimating the motor stall current before you fire up the motor with the ammeter in the loop, otherwise you could end up with no current reading but plenty of smoke =)
If the calculated stall current is a bit greater than 10A that’s alright - the motor will draw close to the stall current for a fraction of a second at startup but after that it’ll drop away considerably, so the ammeter should handle it without issue. If the stall current is really large however (greater than 20A) you may want to consider using either a heftier multi-meter or the shunt resistor method I mentioned earlier.

Unit isn’t here yet and I am lazy…

So I Googled. It seems that 380s are generally rated at 3A and below. I saw one post recommending that you limit the available power to 9A to keep them from overheating. These are RC guys trying to win races. They want it to barely not explode. I want to hold back a little more than that. I want to make decent speed with good maneuverability but still let the motor have a long and happy life.

FYI, it is a boat exactly like this one:

http://www.youtube.com/watch?v=q_iiuzqvPkE

http://www.youtube.com/watch?v=PPNXvVk7Y2I  

and I would be quite happy with the speeds that guy is getting. Even a little less than top speed would be fine. He seems to be timid about keeping it a high speed. You just get a hint of it. I noticed the comment from someone that burned one up and went to his page. He has a video of Barbie being pulled on a tube behind the boat. I suspect that sort of activity may have had something to do with its demise. 

There are probably better platforms out there, but this was being closed out at $11.68 delivered.

ok I wired this up. Except I

ok I wired this up. Except I didn’t have a 47k and i used a 56k. I run the Arduino sweep sample and it just gives me a very low buzzing sound. I am using pin 9 on a Fio.It is a PWM pin, but 3.3v. That counts as logic level for most things. Is that MOSFET an exception? i wired the power straight through first to be sure it spins well. I disconnected the pin and it stops. I connect the pin to pin 8 and it stays stopped. So the PWM is having an effect, just not the one I would like.

but wait there’s more!

 

On a whim, reading a post at arduino.cc, I wired pin 8 straight to the gate and added this code to my loop:

  digitalWrite(8, HIGH);

  delay(1000);

  digitalWrite(8, LOW);

  delay(1000);

guess what? That works. Only problem is, it is full on or full off. Probably workable for this little boat; the motor is slower than I expected (this boat is not the one I linked to; that was a mistake in the listing).

**Correct me if Im missing**<br><p>Correct me if Im missing something but you have a DC motor? The sweep example is for a servo motor.

maybe what you are missing is that Servo == PWM

Yes, it is a DC motor. But the idea behind the circuit I linked to is that with PWM and resistors feeding a logic level MOSFET, you can (well maybe; I was a bit skeptical but optimistic) get the equivalent of an ESC to drive a brushed DC motor at varying speeds. What it is doing with PWM is actually turning it off an on really fast and some MOSFETs will “translate” that into a level of “on-ness”. the one I have seems to be more toward “off-ness”. At least I think so. Waiting for someonewith a better understanding to tell me this MOSFET won’t do that circuit or I have to wire it different.

But are you using the sweep

But are you using the sweep example? A servo pulse is about 2us every 20ms. If we blow that up into easy to relate to numbers it is like giving the mosfet a 1 second high pulse followed by a 10000 second low pulse… that 1 second pulse of current is no where near enough to keep the motor rolling for 10000 seconds.

I haven`t looked at the example code but if you remove all reference to the servo library and replace the servo function with analogWrite you should be ok.

ezekiel is on the money

ezekiel is on the money - you are applying a PWM signal to the MOSFET gate, but it’s at a very low duty cycle, and the frequency is probably not great either.
Your sweep example is probably bouncing between 1ms and 2ms pulses at a rate of ~50Hz, so the period is 20ms. Assuming a triangular sweep waveform, your average duty cycle is a miserable 5% power =)

You could modify the delay in your sample code above to create a simple PWM, 1Hz is a bit on the slow side. Try delay(2); and see what you get from a 50% 500Hz PWM output.

As ezekiel suggests, give analogWrite a try too: “The frequency of the PWM signal is approximately 490 Hz.”

Thanks guys - I think you

Thanks guys - I think you have succeeded in getting it into my thick head. It is not digitally making sense of the PWM as a command, it is actually turning the motor off and on for short intervals and adjusting the ratio adjusts the speed. Your suggestions work. Generating my own PWM with timing seems to work best. 

Can you tell me why the original circuit has the pull down resistor? The Fio seems unable to defeat it. It is an off switch. If I go straight to the gate (found that recommendation in arduino forum) it works. This MOSFET doesn’t seem to confuse floating with high. Nice simple way to turn things off and on. 

The pull-down resistor is

The pull-down resistor is really just to guard against any situation where the gate would be left floating, either by problems with the code, hardware on the output driver, or just because power may be applied to the motor before the micro gets a chance to initialise it’s output pins.

In any case, it’s odd that your Fio cannot overcome the pull-down to turn the MOSFET on… are you sure it’s 56kΩ? Are you using a 1kΩ for the gate resistor?

As you’re implicitly driving the gate both high and low with the Fio, the pull-down is not strictly necessary, but worth adding when you build the ‘real’ motor driver to prevent the MOSFET (and possibly the entire boat!) running away should the Fio suffer some sort of lock-up.