Using a brushless motor with arduino

I came into this project not really understand that there was more to a brushless motor than + wire and - wire, big mistake clearly. So far I have 2 different motors, both with a + (red) wire, a - (black) wire and a yellow "control" (that's an educated guess at the purpose) wire. I quickly realised, after fiddling with varying numbers of batteries for about an hour, that without a "speedo" (Speedometer/control unit thing) I wasn't going to get the motors to spin. A few days later, I have a speedo. It has clear + and - in leads, as well as a 3 wire control(?) lead, and then three wires that come out of the other side of the speedo, each one is blue. So my question is: Can you use a brushless motor with an arduino? Do I have everything that I need to do so right now? What type of control input does a speedo use? (PWM, analogue voltage variation etc) and can I do that with an arduino? Is there some kind of IC/H-Bridge I need or what?

Thanks.

If it is your standard hobby brushless ESC it will take a PWM pulse of 1ms to 2ms (1ms being low throttle, 2 ms being high throttle) with a pulse spacing of 20ms. Most ESCs require low throttle position to be held for a certain amount of time to “arm” them before the motor will actually spin (keeps it from starting if you turn it on at mid throttle or whatnot). The pulse spacing honestly is not especially critical, but pulse width is.

Look into the servo library and example code, you basically just treat the ESC as a servo, drive it all the way to the “low” end and hold till it arms to start and move towards the “high” end to increase motor speed. You will need to experiment with how long to hold low in order to arm the ESC, every one I have used emitted a beep or had a visible indication (LED) to indicate that it was armed.

As for wiring, generally red/black/yellow and + and - in leads - yellow to PWM pin of Arduino, the + and - leads would go to the battery, the red and black wire that go along with the yellow would provide 5V-ish to the receiver (you could use this to power the Arduino likely, it is a Battery Eliminator Circuit so when used in RC you do not need a battery for motor power and a separate one for receiver power). Do a bit of research on using servos with micro-controllers, they are not always happy operating from the same power source (but the BEC circuit likely cleans everything up so it would work wonderfully), and if using different power sources the ESC (or servo) and the Arduino with need to have a shared ground. As for the output wires you should be able to find some documentation on the ESC to properly connect it to the motor, but if all of your wires are the same color and labeled the same (or unlabeled) you may just have to try various combinations (there are only 9) until you find the right one, if it is wrong it will either just stutter or run backwards.

So, talking about the controller, red and black (large) are for the battery and the 3 pin "servo" cable (I say this because it looks like the connector on a servo) is red and black for powering the arduino, and white for control pulses? I can't use the documentation, because despite the name of the supplier on Amazon having "UK" in it, the documentation is all in Chinese. It was less than £10 though, so I imagine it's fairly standard hobbyist stuff and thus should follow standard set-up logic.

Yes, on the controller large Red and Black go to the battery. the battery in this case would generally be a RC hobby sort of battery, the kind you see most often these days are LiPo batteries, they are listed as 1S, 2S, etc. Each S is 3.7V, so a 4S Lipo is a 14.8 Volt battery. The size of your motor is going to determine what rating of battery you will need, as they come in various flavors of milliamp-hour, C (maximum safe continuous discharge rate), and S (number of cells which also determines voltage)

And also correct on the servo connector, it has output red ~5VDC + Black ground, and you can think of white as control or data or whatever you would like, this would be the PWM output from the arduino.

As far as motor hookup don't really worry about it too much, three wires, hook them all up, it will work, just jitter, or run backwards, but it will not damage the motor or the controller in any way if hooked up incorrectly.

Generally when you see people trying to interface a servo with an Arduino they are trying to power the servo off of the same source as the Arduino and they run into issues with electrical noise, that is why you often see discussion of using a separate power source for each. If you use the red/black on the servo connector from the ESC to power your Arduino I believe that everything will work just fine (I have personally done this with no issues at all, the ESC BEC provided a very clean power source and created no issues with noise for me at least). In this case there is no servo to create noise and the Arduino is isolated from the motor by the ESC, but as far as programming is concerned just think of the ESC as a servo.

One question I have about your ESC, I know you say you really have no documentation, but was this ESC advertised as an ESC for a car/truck, or for a Plane/Heli, or was it not specified?

The reason I ask is this, like was discussed earlier most every ESC requires being held in a certain position to arm. If it is a car/truck ESC they generally have reverse as well as forward (and brakes too), so it needs to be held at 1.5ms to arm (90 degree position if you are thinking about it from the servo library point of view). After armed 1.5ms thru 2ms (90-180 degrees) is forward speed, dropping below 1.5ms is brakes (0 thru 89 degrees or so), returning to neutral (1.5 ms or 90 degrees) from brakes and then dropping below 1.5ms again is reverse.

For a plane/heli ESC you will need to hold 1ms (0 degrees) to arm and it is all increasing motor speed from there.

BH72: (I think I have to quote for you to get a notification)

It was advertised as for a quadcopter, so I imagine it's the "arm with 0 degrees" type, though I can easily fiddle around and try to work it out. Will be trying this today, so I'll reply again if I need further help, if I don't then assume that either I was killed by a bear or I figured it out.

Bears are indeed quite a hazard in this hobby!

BH72: snip

So, I've got it going a bit, but I'm running into issues. I'm powering it with 2 9V duracell box batteries for now, because I'm yet to purchase the battery I plan to use in the final project. So what's happening is that it spins, sometimes, but getting it to start is difficult. I'm going to try to fiddle more with the servo settings and see if I can fix this, but more importantly is when it is spinning it seems to do so in pulses. It accelerates, levels out then subsides and stops, before accelerating again. Looking at my arduino's power light, it dims in time with the motor speeding up, then switches off just before the motor in turn stops. The arduino is being powered by the servo connector from the ESC, is it possible that it's not providing a high enough voltage to the arduino, or that the batteries are not providing a high enough voltage to the ESC for it to power the motor at full revs and the arduino at once?

Don't run motors off 9V batteries! Have you ever seen a child's toy with a motor and a 9V battery? They don't exist because the 9V doesn't have enough current supply ability.

Open up a 9V. It's filled with little tiny cells; very narrow. They don't even look like they could supply enough current for a motor.

MorganS: snip

Any suggestions of what I could use? For testing purposes could I use the arduino's 5v supply and power it via USB? Would this at least let it run properly?

Like MorganS said probably it is not a voltage issue, likely the current draw of the motor exceeds the limits of the batteries that you are using. I think 9V batteries are rated somewhere around 500 mAh, you can probably pull an Amp out of a 9V but the battery is going to die rapidly, get pretty hot, and you are going to see a significant voltage drop.

A for instance on the hobby type batteries, a 11.1V 2200mAh battery with a 10C rating can tolerate 20 amp continuous discharge.

Your brushless motor has some sort of "kV" rating, this equates to RPM per volt (like a 2200 kV motor = 2200rpm/volt = 19800rpm @ 9V). Based off of that kV rating there are basically standardized controller ratings, for instance a 2200kV motor would typically call for a 30 Amp or better controller. Your battery will need to be able to meet or exceed the Amp rating for the controller.

The starting issue may be that you don't quite have the "phases" right (the pattern of the 3 wires to the motor not quite right), or it may just be that the battery isn't providing enough "kick" to get it spinning, if you can hand start it and it keeps going it is likely the second case.

Also as far as the Arduino power light, likely when the voltage drops off on the 9v the voltage regulator in the ESC can't provide a stable power source for the Arduino.

I had the same sort of issue with a project where I was using high power LED lights (like 9 watt RGB LEDs), when I was first messing with it I was trying to power it from a 9V, generally the blue portion of the RGB was very weak (because it is the most demanding), and it would stop working all together after just a few minutes. I actually had a 4800mAh 4S LiPo laying around so I tried that and it worked great. I have actually been using it to power all of my experiments since simply because I never have to worry about exceeding the current limits of the battery (the jumper wires on the breadboard would burn way before that happened), and it is rechargeable so I don't have to constantly replace batteries.

I am pretty new to the Arduino world myself, but a long time RC hobbyist, and created quite a few projects (using a different brand of micro controller) that were powered the same way you are powering your Arduino (from the BEC circuit in the ESC), and never had an issue with the ESC not providing good power to the microcontroller. I do not remember right off hand what the maximum current draw rating is on the battery eliminator circuit for the ESCs I used is, but I can tell you that the Arduino and associated components does not come anywhere near overloading it.

DebatedNothing: Any suggestions of what I could use? For testing purposes could I use the arduino's 5v supply and power it via USB? Would this at least let it run properly?

It would likely cook the arduinos 5V supply and/or your USB port. A stack of "D" batteries (6 maybe) would probably offer better results.

Or maybe a 12v car battery....

I have several motors, because they were cheap and I am planning on testing them to see which is best (because when you're buying suspiciously cheap motors from Chinese manufacturers, you can't always trust the Amazon numbers) One is 2200KV, one is 1000 KV (I got this one because the bundle of it, an ESC and two props was cheaper than the ESC alone) and a third is 1200KV. Based off of these claimed numbers, the 2200KV should be the best right? Provided ample power. The phases are right (I'm fairly certain at least) because I could get it to spin by itself with no mechanical jump start needed, so I guess it's the battery issue. I think I may put the project on hold and buy myself a beefy LiPo battery, as I doubt I have any D batteries lying around, let alone 6 of them. Thanks for the help though.

Yes, a LiPo would really be your best bet in the scenario (but I was only half joking about the car battery, it would totally work), when you shop you can figure out the minimum you need to get based off of the kV rating, but it is no harm to go for a larger mAh rating if it falls within your budget (LiPo batteries are certainly not "cheap") as it will offer longer run time and put less "stress" on the battery.

One small word of caution, LiPo batteries are a little temperamental, if you overload them, physically damage them, discharge them too much, charge them wrong, over charge them, let them get too hot, let them get too cold, or maybe even look at them with your eyebrows in the wrong position they tend to swell up and get angry..the swelling indicates that you should abandon use of this battery BTW, charging a damaged LiPo is just asking for a fire (there are some great youtube videos on this). I honestly charge mine inside my brick fire place...

And yes 2200kV will provide the most RPM, but will also drain the battery the fastest.

I am somewhat aware of the dangers of LiPos, and I have a friend with the proper equipment and plenty of experience.

OP - would you mind posting some info about your motor and this "speedo" thing?

Because right now I can't seem to understand whether you have an R/C servo, a brushless motor, or some kind of computer fan motor (which is also brushless - but isn't controlled the same from an "external" perspective).

Ideally - if you could supply us with pictures of your motor and "speedo" thing, and links or other information so that we can obtain specs for the parts - that would be of utmost helpfulness.

Thanks.

The motor is a brushless, RC motor designed for planes, quadcopters etc. The place I purchased it and the ESC is here.