- Home
- >
- Software Development
- >
- What it Takes to Lift a Robotic Arm – InApps Technology 2022
What it Takes to Lift a Robotic Arm – InApps Technology is an article under the topic Software Development Many of you are most interested in today !! Today, let’s InApps.net learn What it Takes to Lift a Robotic Arm – InApps Technology in today’s post !
Read more about What it Takes to Lift a Robotic Arm – InApps Technology at Wikipedia
You can find content about What it Takes to Lift a Robotic Arm – InApps Technology from the Wikipedia website
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.
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.
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).
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.
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | //******************************************************************************** // * File Name : DC_motor_driver // * Author : Radio Shack Corporation // * Version : V1.0 // * Date : 2014/01/27 // * Description : Control direction and speed of a motor // * using pulse width modulation (PWM) // ******************************************************************************** // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // ******************************************************************************** int CH1A = 5; // CH1A, CH1B, CH2A, and CH2B int CH1B = 6; // must be one of 3, 5, 6, 9, 10, or 11 for PWM // int CH2A =5; // Set digital ~5, ~6, ~10, and ~11 for default pins. // int CH2B =12;
// ********************************************************************************* // * Function: Control Motor A // * Input: speed (PWM duty, range = 0-255) // ********************************************************************************* void motorA_forward(int sp) { analogWrite(CH1A,sp); analogWrite(CH1B,0); } void motorA_backward(int sp) { analogWrite(CH1A,0); analogWrite(CH1B,sp); }
// ********************************************************************************* // * Function: Control Motor B // * Input: speed (PWM duty, range = 0-255) // ********************************************************************************* void motorB_forward(int sp) { // analogWrite(CH2A,sp); // analogWrite(CH2B,0); } void motorB_backward(int sp) { // analogWrite(CH2A,0); // analogWrite(CH2B,sp); }
void setup() { pinMode(CH1A, OUTPUT); // Initialize pin for output pinMode(CH1B, OUTPUT); // pinMode(CH2A, OUTPUT); // pinMode(CH2B, OUTPUT);
Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for native USB port only } }
void loop() { Serial.println(“motor backward”); motorA_backward(250); delay(1000); // slow motor before reverse motorA_backward(10); delay(100); Serial.println(“motor forward”); motorA_forward(250); delay(1000); // slow motor before reverse motorA_forward(10); delay(100); } |
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.
Source: InApps.net
Let’s create the next big thing together!
Coming together is a beginning. Keeping together is progress. Working together is success.