Add Motion to Your Project – InApps is an article under the topic Software Development Many of you are most interested in today !! Today, let’s InApps.net learn Add Motion to Your Project – InApps in today’s post !
Read more about Add Motion to Your Project – InApps at Wikipedia
You can find content about Add Motion to Your Project – InApps from the Wikipedia website
One of the areas of physical computing that I’ve wanted to start addressing in this Off The Shelf Hacker column is automation and robotics. Automation is using motors, actuators, solenoids and so on to physically move things, under computer control. Robotics adds in mobility, human (or other) interaction and onboard decision-making capabilities (or “autonomy”).
An example of automation might be to “transform” my Steampunk Presentation Machine camera arm from its folded up position into its proper operational orientation, by using a Python script running on the device’s Raspberry Pi. A robot might be a pint-sized two-wheeled machine, powered by electric motors, that rolls around and follows a line, making a beep every time it turns a corner.
I think there is quite a bit of mileage in applying the physical computing stack to jobs like moving my camera arm or engineering a robot. The concepts are easily scaled up to larger devices. Just use bigger motors, more powerful microcontrollers/single-board-computers and more sophisticated programs.
This week we’ll look at a simple automation example using a microcontroller, a motor controller, a motor and some other parts. Next week we’ll introduce controls, see how they work and go through the code.
The microcontroller for the project is a standard old Arduino Duemilanove, because that’s the latest board of that type, that I have on hand. It has 14 digital I/O pins (six of which provide PWM output) and six analog. We’ll use two of the PMW pins to send signals to the small generic motor control board.
I used a dual-H bridge motor controller from Radio Shack. Seems like it cost around $4, when I bought some of their “going out of business” stock. Here’s a similar one from another company. The boards have 6 control pins and 2 sets of screw terminals. The layout of the control pins is straightforward. Here they are starting from the top.
CH2B – Channel 2 PWM Input
CH2A – Channel 2 PWM Input
GND – Ground
VCC – + Voltage (6 volts)
CH1B – Channel 1 PWM Input
CH1A – Channel 1 PWM Input
Each channel has an A and B terminal that controls the motor in one direction or the other. These are driven by the PWM pins on the Arduino. We won’t worry too much about which one controls which direction, because operations are easily tweaked in the code. This particular board handles about 1 Amp of current, per motor.
The motor is a standard 6-volt hobby model with an attached plastic gearbox. These are available in hobby stores and online. It has quite a bit of torque and is usually used for small wheeled robots. Naturally, the motor should be sized for the amount of load lifted.
The last component needed to make all this work is the external battery. I tried running the tiny motor and motor driver using just the power from the USB cable and the results were disappointing. The motor had very little power and direction/speed control was spotty, at best. Even for such a small motor, a decent power source is definitely required for consistent operation.
I used a plastic 4 AA cell battery pack giving 6 volts. Direction changes and speed were consistent with this setup. Along with the battery, I plugged the Arduino into a standard USB connector.
The project will run in stand-alone mode after programming. We’ll discuss the Arduino code next week.
To make it run in stand-alone mode, I connected the 6-volt power leads directly to the VCC and GND terminals on the motor driver board. To power the Arduino I ran a jumper from the negative side of the battery to one of the GND pins on the board. Likewise, I ran a jumper from the positive battery terminal to the positive pin on the Arduino’s barrel power connector. The Duemilanove spec sheet says that the lower voltage limit is 6-volts, with a recommended input voltage of 7-volts to 12-volts. The Arduino worked in this configuration reliably, without issues, on 6-volts.
Next time we’ll discuss some of the particulars about the program profile of a motor drive project. For example, say you are extending an arm, reach the end of its travel, then want to retract it back to its original position. You could just roll out the arm with the motor, then abruptly reverse it. This will cause an instant change in the motor direction and all the linkages. That kind of behavior causes unnecessary spikes in the loads on the motor, joints, mountings and anything attached to the arm. It’s a very jerky way to do the job.
A much better approach is to ramp the speed of the motor up to extend the arm and when it reaches the desired end of travel, ramp the speed down to 0, then reverse direction. Speed in the opposite direction can then increase to pull the arm back. Gradual acceleration/deceleration is the key to smooth, manageable loads and reliable operation in your motor-drive project.
Next week, we’ll also look at using some input controls to initiate movement sequences and talk about the code layout.
InApps is a wholly owned subsidiary of Insight Partners, an investor in the following companies mentioned in this article: Shelf.
Let’s create the next big thing together!
Coming together is a beginning. Keeping together is progress. Working together is success.