The RaPenduLa: a Video Platform for Studying Mechanical Oscillations

by DaniloR29 in Teachers > University+

186 Views, 2 Favorites, 0 Comments

The RaPenduLa: a Video Platform for Studying Mechanical Oscillations

IMG_0119.jpg

RaPenduLa (RaspPi Pendulum Laboratory) is a video platform featuring a camera module connected to a Raspberry Pi Zero W2 to record the oscillations of various pendulums.

A universal 3D mounting mechanism supports experiments with different inverted pendulums and conventional and magnetic pendulums. The recorded videos are analysed using OpenCV in Python to extract the two-dimensional trajectory of a coloured marker attached to the pendulum tip.

This platform can serve as an engaging science fair project for high school students or as a hands-on experiment for undergraduate physics and engineering labs. It can also be used for demonstrations to introduce the physics of pendulums and the analysis of oscillatory motion.

This Instructable provides complete details for constructing and using the device.

Supplies

IMG_0076.jpg

To build your own RaPenduLa, you’ll need the following materials:

  1. One rectangular perforated metal plate, approximately 60 × 200 mm
  2. 7 M4 screws, 20 mm in length
  3. 2 M4 butterfly bolts
  4. 1 M2 screw and bolt
  5. 1 hexagonal M4 Rod Connector
  6. One 40 cm aluminium ruler
  7. A Raspberry Pi Zero with a Pi Camera (we used version 1.3 of the Pi Camera)
  8. 3d-printed parts (for structural support and assembly)
  9. 1 used red ink Pilot G2 Ballpoint Pens
  10. 1 small metal sphere, 60 mm in diameter, with a central hole (commonly used in decorative bricolage)
  11. 1 metal nail, 20 mm long, that fits through the hole of the metal sphere
  12. 4 round neodynium magnets, 10–12 mm in diameter and 2 mm thick
  13. 1 small screw with a ring (used for hanging picture frames)
  14. A 30 cm long Bamboo stick for food preparations.
  15. 1 used DVD
  16. A4 hard cardboard
  17. A4 photo paper

3D PRINTING

The STL files used to print the assembly parts are provided.

In this project, we have used PrusaSlicer and Cura to prepare the .gcode files and a Creality Ender Pro for 3D printing the parts with a 1.74 mm PLA filament at 0.2 mm vertical resolution.

Construction of the Platform

Slide1.jpeg
Slide2.jpeg

The construction involves preparing a rectangular, breadboard-style platform using two perforated metal plates, each measuring approximately 60 × 200 mm. These plates can be purchased inexpensively at most hardware stores.

Start by 3D-printing the plastic crossed support base (SlidingBase.stl) and insert an M2 bolt into its center (see Figure 1A). To facilitate insertion, heat the bolt using a soldering iron before pressing it into place. Slide the support base onto the plate as shown in Figure 1. Then, you need to fix the central universal holder cylinder (CylUniverstalSupport.stl part) to the base using an M2 screw (see Figure 1B).

Next, attach the four plastic legs to the corners of the plate using four M4 screws.

As shown in Figures 2A and 2B, attach the ruler support (RulerSupport.stl) to the opposite end of the plate and secure it using two butterfly bolts (or regular M4 bolts).

In Figures 2C and 2D, insert the ruler into the slot and secure it using a lateral bolt on the side opposite the measurement scale. To prevent damage, you may wrap a small piece of heavy-duty tape around the ruler before tightening the bolt.

Slide the camera support (CameraSupport.stl) along the ruler. As shown in Figures 2E and 2F, secure it from the back using an M4 bolt. Once again, applying a bit of tape to the ruler can help protect its surface from scratches.

Next, glue an A4-sized rigid cardboard sheet together with an A4 photo paper sheet. Cut a hole in the centre to fit the universal holder cylinder, and trim the edges so the sheet covers the entire platform (see Figure 2F).

Optionally, you can also repurpose an old DVD by gluing a reference scale onto it. Place it over the centre of the paper to help keep the sheet flat, as shown in Figure 2F.

Installing the Raspberry Pi With Camera

Slide4.jpeg

As explained in my previous Instructable, the inexpensive Camera Module 1.3 that I’ve used comes with a fixed-focus lens, which needs to be manually adjusted for short distances by gently rotating it. This is a delicate operation, as improper handling can scratch the lens (see my Mini LED Table Instructable for details).

Attach the Pi Camera to the 3D-printed holder (CameraHolderOnly.stl) using a couple of small screws. Then, insert the camera module into the last hole of the camera support part, as shown in the figure.

You can enclose the Raspberry Pi Zero in the provided case (RasPiZeroCase.stl and RasPiZeroCaseTop.stl), and secure it onto the support part using an elastic band (as shown in Figure 3).

Setting Up the Magnetic Pendulum

Slide7.jpeg

Now, we describe how to set up the platform to analyse the motion of the magnetic pendulum.

First, 3D print the following components:

  1. One arms holder ring (MagnetPositionRing60.stl)
  2. Three arms (MagnetPosBar.stl)
  3. Three magnet holder square cups (MagnetPosHolder.stl)

Insert one square cup into each of the three arms, then attach the assembled arms to the ring as shown in Figure 4A.

Next, insert the ring into the universal cylindrical support on the platform (Figure 4B). Place a neodymium magnet into each square cup and secure it using tape or glue. (We recommend using tape so that the magnets can be easily removed later.)

Now, you need to prepare the pendulum. Below we show an example of how to build one using common household materials. If you don’t have the exact parts, feel free to improvise with similar items.

Start by modifying a screw with a metal ring: use metal cutter pliers to slightly open the ring (as shown in the inset of Figure 4C)—this will allow the pendulum to hang freely. Screw the modified ring into the plastic surface in front of the camera holder part, as shown in the same figure.

Trim the sharp tips off a bamboo skewer or stick to obtain a cylindrical piece approximately 18 cm in length. Then, attach a small red rectangular piece of plastic or paper near one end of the stick—this will serve as a marker for the tracking software (see top inset of Figure 4D).

Recover the white crown-shaped part from a Pilot pen (or another mechanical pen)—this is usually part of the internal button mechanism, as shown at the top of Figure 4D. Fit this part into one end of a hexagonal M4 rod connector. On the other end, screw in an M4 bolt and attach a neodymium magnet to the bolt head, as shown in the bottom inset of Figure 4D.

To hang the stick from the platform, insert the small nail into the central hole of the metal sphere, then insert the nail into the top end of the bamboo stick.

Finally, hang the pendulum by placing the nail into the metallic ring attached to the camera holder (Figure 4E).

Note: The magnets have their north and south poles on the flat top and bottom faces. Therefore, their orientation is important to achieve the desired magnetic effects. For best results, you can align all three magnets on the platform so that the same pole (e.g., north) is facing upward, and orient the magnet on the pendulum with the opposite pole (e.g., south) facing downward. This configuration enhances the interaction between the pendulum and the magnetic field.

Setting Up the Inverted Spring-Pendulum

Slide9.jpeg
Slide8.jpeg

Now, we describe how to set up the platform to analyse the motion of the inverted spring-pendulum.

First, 3D print the following components:

  1. 1 spring-to-platform attachment slider (HelicPendPin.stl)
  2. 1 spring-to-cartridge connector (PinSupportUP.stl)

Recover the metal spring and the ink cartridge from a used Pilot pen (see Figure 5A). Remove the black pen tip from the cartridge and clean the inside of the white cylindrical tube by removing any wax or ink residue. Keep the red cap.

Connect the cleaned cartridge and the spring to the 3D-printed connector part, as shown in Figure 5B and 5C.

Attach the other end of the spring to the attachment slider, and insert the assembly into the universal cylindrical holder on the platform (Figure 5D and 5E).

You can adjust the mass of the oscillating pendulum by adding small O-rings that fit around the cartridge (Figure 5F).


It is possible to modify the spring-to-platform attachment slider to accommodate different types of springs. Figure 6 shows another example of an inverted spring pendulum. In this case, the tip of the spring has been 3D printed, and a red dot has been painted at its center to facilitate motion tracking. To help you design your system, we have included the OpenSCAD files for the spring-to-platform attachments of both spring configurations, as well as the spring-to-cartridge connector and the spring cap used in the second setup.


$fn=100;

// Small spring

module HelicPendPin() {
translate ([0,-0,4]) cube ([14,7.7,2.8],center=true);
translate ([0,-0,7]) cube([14,4.7,4],center=true);
translate ([0,-0,7]) cube([14,2.8,4],center=true);
translate ([0,0,7]) cylinder($fn=100,h=10, r=1.7, center=false);
}
module ConnectingPinUp() {
cylinder($fn=100,h=10, r=1.7, center=false);
translate ([0,0,-9]) cylinder($fn=100,h=10, r=3, center=false);
translate ([0,0,-18]) cylinder($fn=100,h=10, r=2.4, center=false);
}

// Large spring

module HelicPendLargePin() {

translate ([0,-0,4]) cube ([14,7.7,2.8],center=true);
translate ([0,-0,8]) cube([14,4.7,9],center=true);
translate ([0,-0,7]) cube([14,2.8,4],center=true);
translate ([0,0,9.5]) cylinder($fn=100,h=10, r=5.0, center=false);
}

module TopLargeSpringLid() {

translate ([0,0,-7]) cylinder($fn=100,h=5, r=8, center=false);
translate ([0,0,-7]) cylinder($fn=100,h=10, r=6.4, center=false);
translate ([0,0,-9]) cylinder($fn=100,h=4, r=3, center=false);
}

//ConnectingPinUp() ;
//HelicPendPin();
//HelicPendLargePin()
//TopLargeSpringLid();

Recording and Tracking the Pendulum Tip Trajectory

Program.jpg

Video recording is performed from the Raspberry Pi console using the following command:

raspivid -w 640 -h 480 --framerate 90 -t 20000 -o output.h264 -md 7

This command records a 20-second video at a resolution of 640×480 pixels and a framerate of 90 frames per second. The output is saved to a file named output.h264.


The tracking of the 2D trajectory


The tracking of the 2D trajectory of the pendulum tip from the video is then performed using a standalone Python application that detects the red colour references in the two types of pendulum. A Lite version of the program is provided.

The application is designed to extract and visualize the motion of a colored spot—such as a red marker—from a recorded video. It is particularly suited for analyzing pendulum trajectories and other oscillatory motion in physics experiments. The interface is built with Tkinter for usability and OpenCV for real-time video processing.

To run the script, use Python 3 with the following command:

python3 LSTV2.1Lite.py

The program will start with the Tinker interface shown in Figure 7A. Users can load video files (Load video file button) in .AVI or .MP4 format via a simple file dialog interface. Once loaded, video frames are displayed in a Tkinter canvas. The program uses HSV (Hue, Saturation, Value) filtering to isolate a color spot (e.g., a red dot on the pendulum tip). The default HSV range is optimized for a red marker but can be interactively adjusted.

Clicking the HSV Cal checkbox opens a calibration window with slider controls to fine-tune the HSV ranges for spot detection. A preview window displays the filtered output, making it easier to ensure proper color segmentation. On calibration exit, HSV filter settings, offset values, and fps are saved to a LSTparam.txt file in the working directory. These parameters are automatically loaded at startup for a smoother user experience.

The detected spot is overlaid with a red circle on the video. The Line/Points checkbox lets users switch between displaying the trajectory as a continuous line or individual points. An On/OFF Red Circle option is available to disable the visual marker if needed.

The user can manually input the frame rate (fps) of the video (e.g., 90 fps for Raspberry Pi Camera). After loading the video, a separate window plots the X and Y coordinates of the spot as a function of the frame index. This helps identify and trim non-relevant segments (e.g., setup portions in high-speed videos). START and END entries allow selecting a range of frames to focus the analysis.

Downloads

Example of Tracking

ResultMagPend.jpg
Result1.jpg

In Figure 8, examples of tracking different trajectories generated by the magnetic pendulum.

In Figure 9, examples of tracking different trajectories generated by the second inverted helical spring pendulum.

Conclusions

Screen Recording 2025-04-21 at 19.06.51.mov.gif

RaPenduLa offers a low-cost and engaging way to explore the dynamics of pendulums through hands-on experimentation and modern video analysis techniques. With its modular 3D-printed structure, it supports a wide range of setups—from simple magnetic pendulums to inverted pendulum systems. The combination of Raspberry Pi and OpenCV allows students and enthusiasts to capture, process, and analyse motion data with ease.

Whether you’re a student working on a science fair project, an educator seeking interactive lab activities, or a hobbyist curious about pendulum physics, RaPenduLa provides a versatile platform for learning and discovery. We hope this guide inspires you to build your own and experiment with the rich world of oscillatory motion.