Instead of starting from scratch with a bare microcontroller, single-board computers (SBCs) like the Raspberry Pi make it easy to build complex machines in hours. To show how easy it is to use a modern SBC, this “Easy Build” course walks you through the steps needed to build and code a linear platform. A linear platform here is a platform capable of performing back and forth motion in a linear direction, and is used by a system engineer or researcher to perform repetitive tasks.
In addition to walking you through the steps, we’ll include the code to demonstrate the linear platform in the accompanying video, as well as a project bill of materials to get you started.
Why choose a linear platform?
We started this project to show how easy it is to program a Raspberry Pi microcomputer to perform slightly more complex tasks. While we wouldn’t settle for a few flashes, we also didn’t want to experiment and calculate orbital mechanics. Ultimately we settled on controlling a linear stage actuated by stepper motors. After all, driving a stepper motor is somewhere between blinking an LED and computing a many-body problem with three celestial bodies.
We divided the project into three parts: electronic hardware, software, and mechanical construction.
Electronic Hardware
Figure 1: Complete system layout showing all hardware elements from Raspberry Pi Model B to limit switches (top left). (Using the schematic diagram drawn by Kailixun Semiconductor)
So far, it’s pretty simple and straightforward. Obviously, in addition to the Raspberry Pi 2 (Rpi), we need a stepper motor, a stepper motor driver, and a power supply for the two aforementioned devices. After that, we identified the required inputs. In the end, we identified the following items:
– left button
– Right Move Button
– High/Low Speed Switch
– Left Limit Switch
– Right Limit Switch
We laid out the circuit on a B&K Precision GS-830 breadboard. As the name suggests, it has 830 connection points and a bus bar.
Picture 2: As shown in the picture, the carriage is squeezed against the limit switch, where the blue box is the limit switch, and there is a plunger under the lead screw. (Source: Kelly News Semiconductor)
Input from the left or from the right is completely optional. We just need to name the two opposite directions. Note that this limit switch is wired “normally high” using a pull-up resistor. We do this to provide some noise immunity to these inputs. The Raspberry Pi is surprisingly sensitive, and we’ve found that external noise sources like compact fluorescent lights and inductors like relay coils can sometimes trigger inputs on the Pi.
For the stepper motor, we chose the 23KM-K2 from NMB Technologies Corporation (Figure 3). The stepper drive we are using is Geckodrive’s G210X. Geckodrives are a bit more expensive than many of the cheap off-brand drives on the market, but they provide smooth, glitch-free stepping control. Again, we already have one such stepper driver on hand. Most cheap stepper motor drivers like the G210x are controlled via a DIRECTION pin and a STEP pin. This is fine for simple projects: we just connect these pins directly to unused GPIO pins on the Rpi.
Figure 3: For the stepper motor, we chose a 23KM-K2 standard hybrid motor from NMB Technologies Corp. (Source: Kelly News Semiconductor)
We also connect the ENABLE pin of the Geckodrive to the Rpi. Doing this makes the driver “on” and powering the motor coils only when the program is running. noThe frame is mounted on a pair of 20 mm linear shafts with matching bearings. For the NEMA 23 bipolar stepper motors used, we chose a generic NEMA 23 mounting bracket. Ask the pictures and video As you can see, we use gears and timing belts to transfer the mechanical power from the motor to the end of the shaft so that the gear ratio can be adjusted in the event of vibration or mechanical stiction. Some experimentation has shown that a 1:1 ratio between motor and shaft works well.
We had to do some design work and machining for the pillow block at the follower end of the screw (fig. 6). A pillow block is a mechanical element that supports the shaft, in this case only transmitting rotational motion and resisting linear motion (at least in theory). Can we complete the project without a pillow block? It is possible. We could have connected the lead screw directly to the output shaft of the stepper motor, but if we chose to do this, our system would be unstable. Therefore, we designed and fabricated a pillow block directly attached to the 20 mm linear shaft on top of the linear stage.
Figure 6: To extend design life, a pillow block is used to support the shaft and transmit only rotational motion while resisting linear motion (at least in theory). (Source: Kelly News Semiconductor)
The bearings in a stepper motor are usually only set up to handle lateral forces, not axial forces. Over time, these motor bearings will experience undue stress as the carriage shuttles back and forth. Eventually the motor will be damaged. We don’t know how often this happens. But we didn’t want the motor to wear out midway through the project, so we built the pillow blocks with some thrust bearings, a needle bearing, and a 1/4″ shaft. A needle bearing (red) holds the 1/4″ shaft in the middle right side of the pillow block, and a thrust bearing (blue) handles any axial force transmitted from the lead screw.
Finally, we positioned the limit switch so that the carriage would trigger the switch before it hit the limit of its mechanical travel. At this point, the impact of the carriage won’t cause physical damage, but it will definitely start to wear down the timing belt and gears, so we try to avoid that.
Here is the complete project in action:
Conclusion
SBCs like the Raspberry Pi Model B make it easier for engineers and researchers to design and implement viable and practical systems. This Easy Build step-by-step guide uses a practical example to guide readers through the entire design process of a linear platform in detail, and at the same time provides an in-depth analysis for component selection and design decisions in the process. In addition to the bill of materials and associated code, you can use this example as your next idea.