Favorite Social Media Timesink
When you take a break from work, where are you going?
Video clips on TikTok/YouTube
X, Bluesky, Mastodon et al...
Web surfing
I do not get distracted by petty amusements
CI/CD / Software Development

Off-The-Shelf Hacker: What it Takes to Lift a Robotic Arm

Sep 17th, 2016 9:07am by
Featued image for: Off-The-Shelf Hacker: What it Takes to Lift a Robotic Arm

Last week, we started talking about automation and robotics.

We also kicked off a quick project to add motion to a simple mechanism, moving an arm back and forth with an electric motor, a motor driver and an Arduino. We looked at the parts and the general project layout, now we’ll go through the build and the basic code to make physical actions happen. Next week, we’ll dig into the controls, like actuation buttons, limit switches and an E-stop. We’ll finish up with ideas on enhancements and adding functionality for a possible version 2.0.

Before we start discussing the mechanics and code, I need to address the wrong turn I took with the 6-volt motor and plastic gearbox.

Quickly prototyping a new or untested idea, from a blank sheet, is a gamble. You can’t possibly know what you don’t know, until you build something, test it and analyze the results. The best you can do is use your own vast knowledge and engineering experience to make your best initial decisions, then build and test. The term “fail fast” certainly applies to building any kind of physical device. I tend to grab parts, mock up the physical mechanism then flip the switch to “ON” and see what happens. Occasionally, I get it wrong and it just doesn’t work as envisioned. Another apt term comes to mind, “iterate”.

That was the case, since last week’s story. Here’s what happened and how I got back on track.

6-volt Motor Fail

Readers will note that the original parts list showed a 6-volt motor with a dual-shaft plastic gearbox. I decided a quicker, less time-consuming way to get the job done was to scavenge one of the 6-volt wheel motors (single shaft) from an old two-wheeled MakeBot robot frame. They have a 2-inch diameter plastic gear with a tight-fitting rubber ring that acts as a tire.

Using the single-sided motor made it easy to fab up a couple of mounting brackets to mount the arm pivot about 1-1/2 inch above the mounting surface. The center of the motor shaft was then aligned with the arm pivot point and an L-bracket made to hold the motor at the right height.

With the motor properly aligned with the arm pivot, the idea was to drive the arm, with a pin keyed to one of the holes in the plastic wheel. Take a look at the photo.

6-Volt-Motor/Plastic Gearbox

6-volt motor/plastic gearbox

After mounting the 6-volt motor/gearbox to the Steampunk Presentation Machine camera arm and running the code on the Arduino, it became painfully obvious that the pint-sized motor wasn’t up to the task of lifting the arm. It was just too small. Increasing the motor input voltage to 12-volts, minimizing binding in the mechanism and changing the pulse width and timing code all were futile. I could have spent time, up front, making motor torque measurements, calculated the amount of power needed to control the arm, or started with a big honking motor. But, I didn’t.

That’s the way it goes sometimes. Design, build, then fail fast and adjust your approach.

Metal Gearbox Reroute

Fortunately, I had a beefier motor and gearbox available to remedy the situation. I had purchased the motor for about $13 from Skycraft Electronics, a while back, for another project.

Big Motor With The Metal Gearbox

Big motor with the metal gearbox

Supplying 6-volts to the motor power terminals gave me about 14 RPMs, at the gearbox output shaft. That’s the same as 5040 degrees of rotation per minute. Or, 84 degrees per second. In its current configuration, we have about 170 degrees of arc, we can swing the arm, before colliding with the wooden base or the Raspberry Pi, at the back of the machine. So with the 84-degrees-per-second number, we can roughly calculate how far the arm will swing based on how long we run the motor, according to our code. My example code ran the motor forward for 1000 milliseconds and backward for the same amount of time. The arm traveled through about a 90-degree arc, in the middle of its travel envelope.

It turned out that the biggest challenge was to fab up an actuator arm for the shaft. The end of the shaft is a D-shaped cross-section. I ended up bending a piece of 1/8-inch by 3/4-inch aluminum stock into an L-shape and drilling a couple of holes on the short side to clamp the piece to the flat part of the motor shaft with a steel strap. Ideally, you’d use some kind of broached D-shaped adapter to connect to a lever that attached to the camera arm. I didn’t have any adapters, so I just “fast prototyped” the L-bracket and kept going. Building the lever took about a half-hour, with the drill press, vise and the BFH (big hammer).

Close-up of Motor Lever

Close-up of motor lever

I also built a couple of simple L-brackets to attached the motor on the presentation machine base. They bolted up to the bottom of the gearbox housing. The gearbox shaft needed to align with the centerline of the arm pivot so there wouldn’t be any binding.

Big Motor L-Bracket

Big motor L-bracket

Let’s Look at the Code

Information on the Radio Shack dual-channel motor driver, model 2730851 is a little hard to find, on the web. Fortunately, GitHub had an example sketch and spec sheet. I just pulled in and modded the sketch to my needs. Since only one channel was needed, the other channel was commented out.

As you can see in the code, I used digital pins 5 and 6, which have pulse width modulation (PWM) capability. A couple of functions, motorA_forward and motorA_backward actually contain the analog_Write() functions and are called from the main program loop. You give the functions a parameter from 0 to 255 to specify the duty cycle for the PWM. Then, tell the program to run the motor (using the delay() function) for a certain number of milliseconds to move the arm to the desired angle.

You’ll notice that the motor doesn’t abruptly reverse direction every second. Rather it reduces it’s speed at 100 milliseconds prior to reversal. It’s common practice to ramp the speed up and down before changing directions, so as to minimize spike loads on the arm joints and mechanisms. Gradual acceleration/deceleration is the key to smooth, manageable loads and reliable operation in your motor-drive project.

Moving Forward

There’s also isn’t any kind of positioning feedback, in this version. We simply run the motor, in one direction or the other for a certain period of time. There is no initial position verification or continuous monitoring of the arm position. There aren’t even any limit switches that keep the arm from hitting its physical ends of travel.

All that’s OK, because my intention was to explain the basics of using a motor, motor driver and Arduino to control a simple pivoting arm.

Next week, we’ll also look at using some input controls to initiate movement sequences and talk about limit switches, positioning feedback and an emergency stop button. Enhancements and possible new features will also be on the agenda.

Group Created with Sketch.
THE NEW STACK UPDATE A newsletter digest of the week’s most important stories & analyses.