Let's Make Robots!

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:


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:


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...

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

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. 

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.


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);


  digitalWrite(8, LOW);


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 I`m missing something but you have a DC motor? The sweep example is for a servo motor.

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 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 - 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 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 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.