Here's the presentation: https://goo.gl/XTrMXF
Developing my first hardware con talk in the open
To make the experience fit your profile, pick a username and tell us what interests you.
Here's the presentation: https://goo.gl/XTrMXF
For those at the event, I plan to have demos of the following:
Very much a WIP! But I have some time, right???
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 (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.
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.
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 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.
* 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.
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.
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.
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.
Become a member to follow this project and never miss any updates