Photo by Hep Svadja
Photo by Hep Svadja
makeactionbookcover copy
This project is excerpted from Make: Action by Simon Monk, available at the Maker Shed and fine bookstores.

Linear actuators convert the fast rotation of a DC motor into slow linear movement, and they can provide quite a strong pushing or pulling force.

You can easily control these actuators using a simple H-bridge circuit — put it together with an Arduino and a bit of woodwork, and you can make yourself an automatic crusher for beverage cans — no soldering required!

H-Bridges

h-bridgediagramAn H-bridge is a simple circuit that uses 4 switches to change the direction of a DC motor (forward or reverse) by simply reversing the polarity of the motor’s connections.

With all 4 switches open, no current can flow through the motor. However, if switches S1 and S4 are closed, but S2 and S3 are open (as shown here), current will flow from the positive supply to terminal A of the motor, through the motor and S4 to the negative supply, and the motor will turn in one direction.

If S1 and S4 are now opened and S3 and S2 closed, the positive supply will be applied to terminal B instead and flow out through the motor and S2 to reverse the direction of the motor. Interestingly, you can brake the motor by closing S1 and S3 simultaneously (or S2 and S4). Just don’t close S1 and S2 at the same time (or S3 and S4) or you’ll cause a short circuit!

The L298 chip in your H-bridge module contains 2 miniature H-bridge circuits that work in exactly this way.

CAUTION: Linear actuators are strong. This project is about crushing beverage cans, but the actuator will quite happily crush a hand or anything else that you put into the crushing area. So be careful, especially while you’re getting it to work, when there is a temptation to adjust and intervene.

YouTube player

What will the next generation of Make: look like? We’re inviting you to shape the future by investing in Make:. By becoming an investor, you help decide what’s next. The future of Make: is in your hands. Learn More.

Project Steps

1. WIRE THE CIRCUIT

Figure A illustrates the wiring diagram for the project, and Figure B shows a close-up of the Arduino and H-bridge module.

cancrusherfiga
Fig. A
Photo by Simon Monk
Fig. B. Photo by Simon Monk

The L293 module has jumper pins that by default keep its H-bridge circuits enabled, and so only the two Arduino outputs connected to IN1 and IN2 are needed.

Conveniently, the H-bridge module includes a voltage regulator that provides a 5V output that you can connect directly to the 5V pin of the Arduino to supply it with power.

2. BUILD THE CRUSHER

The basic structure of the crusher is a length of 2×4 wood. At one end, the actuator is anchored using the fixtures supplied with it. The actuator’s shaft is then fixed to a block of wood that crushes cans against an end stop. Two plywood sides help prevent the can escaping while it’s being crushed.

I haven’t used exact dimensions, because your actuator is likely to be a little different in size than mine. The best way to get it right is to place the actuator on the 2×4 and then calculate the spacings. Remember to leave a bit of a gap between the fully extended crushing surface and the end stop; otherwise, the machine might push itself apart.

3. PROGRAM THE ARDUINO

Click here to download the project code file can_crusher.ino. Here’s how it looks:

const int in1Pin = 10;
const int in2Pin = 9;
const long crushTime = 30000; //
void setup() { //
pinMode(in1Pin, OUTPUT);
pinMode(in2Pin, OUTPUT);
crush();
stop();
delay(1000);
reverse();
stop();
}
void loop() {
}
void crush() {
digitalWrite(in1Pin, LOW);
digitalWrite(in2Pin, HIGH);
delay(crushTime);
}
void reverse() {
digitalWrite(in1Pin, HIGH);
digitalWrite(in2Pin, LOW);
delay(crushTime);
}
void stop() {
digitalWrite(in1Pin, LOW);
digitalWrite(in2Pin, LOW);
}

Although the actuator will automatically stop when it gets to the end of its travel, this crushTime period (30 seconds for my motor) sets how long the motor should be on, before reversing.

The setup function controls the whole operation of the project. After setting both control pins to be outputs, it immediately starts the crushing action using the crush function.

Be Nice to Your Motors

Imagine a car driving along and then suddenly being thrown into reverse gear — that’s pretty much what you’re doing if you suddenly reverse the direction of a motor. For small motors without a great deal of mass attached to them, this isn’t normally much of a problem. But you may find that if you’re using a Raspberry Pi or Arduino board that’s powered from the same power source as the motors, then the Pi may crash or the Arduino may reset. This happens as a result of the large current that flows when you suddenly switch directions, causing the board’s power supply voltage to dip.

For larger motors that are driving something with a lot of inertia, sudden changes in speed or direction can cause big problems. The resultant large currents may damage the H-bridge, and there’s also the mechanical shock to the bearings of the motor.

This is something to bear in mind when designing control software for larger motors. One way to be nicer to your motors is to precede any change in direction by setting the control lines to let the motor stop, pausing for enough time for it to actually stop before setting it running again in the opposite direction.

In Arduino, setting up this kind of delay function might look something like this:
forward(255);
delay(200);
reverse(255);

In our can crusher code, you can see we’ve set full stops and also a delay of 1 second (1000 milliseconds) between crushing and reversing.

4. SMASH CANS!

Push the Reset button on the Arduino to trigger the crushing action (Figure C). Whenever the Arduino resets, it automatically starts to move the linear actuator. Smoosh!

cancrusherdemo
Fig. C

GOING FURTHER

H-bridges can be used to control other types of motors, including stepper motors. They can also be used to switch power to other devices, such as Peltier heating and cooling elements. You’ll learn all this and a lot more in my book, Make: Action.