close-circle
Close
0%
0%

Supercon talk: a pragmatic guide to motor controls

Developing my first hardware con talk in the open

Similar projects worth following
I was fortunate enough to be selected as a speaker at the first-ever Hackaday SuperConference! I've been building actuated projects and robots for while and while motor control isn't rocket science, sifting through articles, videos and datasheets takes forever. I hope sharing the tl;dr will help out a lot of folks in the future.

I also thought it would be fun to develop the talk right here on hackaday.io, out in the open. Besides sharing my thought process, I hope experts on here can find my dumb mistakes or give additional pointers.

Let's get started!

Here's the presentation: https://goo.gl/XTrMXF

  • 1 × Brushed DC motor
  • 1 × Bipolar stepper
  • 1 × Quad-type BLDC
  • 1 × Standard Hobby Servo
  • 1 × Standard Transistor (2N3904, 2N2222A)

View all 15 components

  • Demos

    Jonathan Beri11/14/2015 at 01:07 0 comments

    For those at the event, I plan to have demos of the following:

    • Brushed DC, 555
    • Brushed DC, Mosfet H-Bridge, Arduino
    • Stepper, A3967, Arduino
    • Stepper (or 2 BDC,) drv8830, Arduino
    • Servo, Arduino
    • Brushless, ESC, Arduino

  • Starting the presentation

    Jonathan Beri11/12/2015 at 22:09 1 comment

    https://goo.gl/XTrMXF

    Very much a WIP! But I have some time, right???

  • Brushless DC motors: microcontrollers & drivers

    Jonathan Beri11/12/2015 at 06:17 0 comments

    BLDC motors are effectively Steppers with three coils instead of two (often called 3-phase.) That means three half bridges and three PWM signals will turn the motor. In fact, if you open up a hobby ESC you'll find six mosfets and either an 8051 or AVR.

    BLDC's usually come with built-in Hall effect sensors that help encoding position. If a BLDC doesn't have sensors (sensorless,) or they're being ignored, than you need to account for an initial unknown speed. That usually works when the exact speed is not critical or there is feedback from another source (back EMF or a thing being cooled, for those interested.)

    There are of course specialized drivers for BLDCs. There's simpler/cheaper ones just for Fans and full-fledged 3-phase drivers that are driven by PWM inputs (and a few via SPI/I2C.) I personally haven't used these parts but Microchip has a variety of fan drivers like the MTD6502B or a more traditional 3-phase driver like the MCP8024.

  • Brushless DC motors: overview

    Jonathan Beri11/12/2015 at 03:44 0 comments

    Brushless DC motors (BLDC) are meant for SPEED. They can get to high RPM quickly and reliably, which is why they are used in drones, mills and cooling fans. They also can provide a good amount of torque, which is why they're also used in e-bikes. They have a common ancestry with steppers, which means we already somewhat know how to control them.

    PROS

    • $$ - price keeps coming down thanks to hobby drones. Larger e-bike motors are getting mass produced as well
    • Can turn really quickly, especially at low-end acceleration
    • Control is straight forward, especially with hobby Electronic Speed Controllers (ESC)
    • Can be made lightweight

    CONS

    • Not good for fixed-positioning
    • Sensored type are closed-loop and therefore need more electronics
    • Current hog

  • Servo motor: microcontrollers & drivers

    Jonathan Beri11/11/2015 at 07:18 0 comments

    A PWM signal is a PWM signal is a PWM signal. So generating the right duty cycle from an MCU is trivial. You can add as many servos as you have PWM pins and even multiplex it of sorts with counters. See Servo.cpp in the Arduino HAL (there, I said it) for an example. Note that if you plan on doing sequenced animatronics, going with an MCU is the only sane solution. If you have a beefy MCU you can use the available pins or rely on a multi-channel driver like the PCA9685 previously mentioned. That leaves you overhead for more advanced processing like inverse kinematics.

    There's a nice benefit of Servos I forgot to mention. Because they have a power pin, you don't have to worry about the output current of your driver. Any old logic high will work and the the servo manages it's own current draw.

  • Servo motors: simple & discrete components

    Jonathan Beri11/11/2015 at 07:05 0 comments

    Servos move based on input frequency. That comes from a duty cycle of a given length. Each servo has a specific duty cycle that maps to a particular degree. For example, providing 1.5ms duty cycle @ 50hz to a standard hobby servo will move the shaft to the center position. Shorten the duty cycle to 1.0ms and the shaft turns all the way to the right. Lengthen it and it turns all the way to the left.

    Are old friend the 555 can help us out here. Just building a servo tester would be useful. But you could do something like using a rotary switch to physically toggle a light switch. Isn't there a crowdfunding thing for just that?

  • Servo motors: overview

    Jonathan Beri11/11/2015 at 04:24 0 comments

    Servo motors are unique in that they can move to the angle your want and stay there - even when something pushes on it. On the inside there is a closed-loop control system but we can treat the thing as a black box (literally, though they sometimes come in blue.)

    There's 2* very distinct flavors of Servo - one for the RC plane/animatronic market and one for high-end industrial automation. There are other nuances like plastic vs metal gearing or analog vs digital circuitry, but they are all controlled in generally the same way.

    PROS

    • $$ (Hobby-grade) - if you buy direct from China in volume they're not much more than BDCs
    • Position shaft easily and stay there
    • Control protocol is easy, often doesn't need drivers
    • Casing makes them easy to mount
    • Lipo-friendly voltages
    • Industry-defined standard sizes

    CONS

    • $$$ (Industrial-grade)
    • Not meant for continuous rotation but hacks to exist
    • Needs constant signal unlike Steppers

    * there is a third flavor sometimes called "Smart" servos that have an on-board MCU but they're a different beast and out of scope for the talk.

  • Stepper motors: microcontrollers & drivers

    Jonathan Beri11/10/2015 at 16:38 0 comments

    Any modern MCU can generate the PWM we need to drive a stepper. As before, we just need the right H-bridge for our power demands and at least 4 GPIO. I'd always prefer to use a hardware PWM and a little bit of counter/toggling code but in a pinch you could bit-bang with a software clock signal.

    A better option are specialized stepper drivers. They usually require 2 pins (PWM & direction) and are awfully cheap thanks to 3D printers. The A4988 is at the heart of every RepRap and a single unit module with heatsink is a buck and change. In addition to price and pin count, these driver boards also usually have an output for current draw, something key to closed-loop system (a topic for another time.) Other popular chips include the DRV8824, DRV8834 (low-voltage) & A3967 - used in the OSH EasyDriver.

    As a third option there exists drivers that can be controlled over the various communication protocols. Pick a vendor and you'll probably find a part with SPI or I2C. As a sample, the DRV8830 & PCA9629 can be controlled by I2C while something like the L6470 & A4980. Note that there are less options for these type of parts and are usually pricier than the step+dir driver.

  • Stepper motors: stepping

    Jonathan Beri11/09/2015 at 19:49 0 comments

    The additional coils in a Stepper enable finer-grained positioning and a therefore more things to know about. We need to understand how we can create steps in order to get the correct accuracy, torque and be able to select the correct controller.

    In the simon game model, each coil is energized in succession. Each coil is also energized @ 100%, causing the motor to move in 90 degree steps. This is called a full step.

    If we energise two adjacent coils, the magnet on the shaft will move in between the coils, doubling the resolution to 45 degrees per step. This is called a half step.

    We don't have to fully energize coils. We can partially energize them and at different power levels. This creates a ratio of magnetic pull on the shaft. If a coil is at 75% and the adjacent coil is 100%, the ratio is 3:4. The motor will move 1/4 the way between the coils or 11.25% degrees per step. Precisely control the ratio and smoothly transition between the values (using sin waves instead of square) and you get microstepping. The more interesting projects rely on microstepping so keep an eye out for that term in datasheets and articles.

    Before this section ends I should admit that I'm a big 'ol liar. Modern steppers aren't 4 coils and a science-class magnet on a pole. They actually have many coils and many little magnets in a tooth-shaped pattern. Here's a gorgeous shot from Adafruit:

    That said, for the most part the coils are wired in parallel and the control mechanism is the same.

  • Stepper motors: common ICs

    Jonathan Beri11/09/2015 at 16:10 0 comments

    I should spend a bit of words explaining what's inside a stepper to understand how they can be made to move. As a generalization, a stepper has a magnet on a shaft and 4 coils in a "plus" pattern around the perimeter. When a coil is energized as an electromagnet, the magnet on the shaft rotates to the next coil. Energize the coils in succession, the motor turns one way. Reverse the order, it turns the other way. Progress through the coils more quickly and the motors move faster. Do nothing and...the motor brakes (more on that in a bit.) You can find animated diagrams online explaining this pattern but I like to visualize the coils like a game of Simon.

    In a basic Bipolar motor, you cycle through the coils by energizing 1 of the say even coil sets, then the odd and then reversing the polarity on the even, etc. Practically, that's no different than controlling 2 BDC motors, albeit with different logic. Luckily that means any of the H-Bridge solution we've previously discussed will work just fine. If you need to move a stepper continuously and don't care about positioning, a 555, XOR Gate & flip-flop will turn that stepper. You have to make sure you have enough power from your controller, so selecting the right H-bridge/Mosfet for your demand is just as important as before. The L293D can be found in maker kits everywhere because it Just Works™ and therefore breakout boards are super cheap for prototyping.

    And braking? We actually kinda get that for free. If the cycling stops but one coil is energized, the motor will stop quickly and even hold in place - something unnatural for the BDC counterpart. To freewheel you actually have to turn off all coils. If you have a 3D printer you might have experienced the need execute a "disable motors" command in order to move around the printer bed or extruder.

View all 18 project logs

Enjoy this project?

Share

Discussions

Grazfather wrote 11/08/2015 at 22:41 point

Great so far!

  Are you sure? yes | no

Jonathan Beri wrote 11/07/2015 at 01:25 point

Folks following along at home - I'm considering skipping A/C brushed motors in the interest of time. I'll probably still do a write up on here but not include it in my talk. Thoughts

  Are you sure? yes | no

zakqwy wrote 11/09/2015 at 15:20 point

Yeah, I'm planning for 20 minutes to pretty much fly by..

  Are you sure? yes | no

Kumar, Abhishek wrote 10/20/2015 at 09:41 point

Congratulations on getting selected for the conf talk! Unfortunately I won't be able to stay till the next weekend but I'm following it here. Personally I'm more interested in the PID / advanced motor control part, though.

  Are you sure? yes | no

esot.eric wrote 10/21/2015 at 05:25 point

I never made it to the I or D parts, myself... but have found that a simple "P" feedback-loop can accomplish quite a bit, as far as positioning-systems... (and that's easy to move up to speed-control). I've done some high-ish precision CNC-type stuff with nothing more than P (and DC-servo-motors... with gear-reduction). And some recent experiments with attaching encoders to "hobby motors" (like the one in the image, and others), have shown surprising (to me) accuracy with positional-controlling of these motors usually meant for extremely fast rotational-speeds.

Cool talk, yo. Not gonna be able to make it to the conference, so thanks for doing this!

  Are you sure? yes | no

Sophi Kravitz wrote 10/19/2015 at 17:06 point

Hey I additionally started another project for attendees and speakers. I'll link to this one Jonathan.

  Are you sure? yes | no

zakqwy wrote 10/19/2015 at 15:19 point

As a fellow first-time conference speaker, I'm excited to see this project. Looking forward to seeing your ideas!

  Are you sure? yes | no

Jonathan Beri wrote 10/19/2015 at 15:46 point

Rad! Looking forward to yours as well. What's your session?

  Are you sure? yes | no

zakqwy wrote 10/19/2015 at 15:52 point

It's called, "You Can Take Your Hardware Idea Through Pilot-Scale Production With Minimal Prior Experience And Not Very Much Money, So You Should Do It NOW!!"

Pretty much what it says. I'm going to use #NeuroBytes as a case study for scaling up a hardware concept without any real experience, but I haven't really gotten the specifics together yet..

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates