diff --git a/images/img_robotic_arm1.png b/images/img_robotic_arm1.png new file mode 100644 index 0000000..f7f26b7 Binary files /dev/null and b/images/img_robotic_arm1.png differ diff --git a/images/img_robotic_arm2.png b/images/img_robotic_arm2.png new file mode 100644 index 0000000..e6315c0 Binary files /dev/null and b/images/img_robotic_arm2.png differ diff --git a/images/img_robotic_arm3.png b/images/img_robotic_arm3.png new file mode 100644 index 0000000..0ed8d4c Binary files /dev/null and b/images/img_robotic_arm3.png differ diff --git a/images/jumper_wires.jpg b/images/jumper_wires.jpg new file mode 100644 index 0000000..9d6bc06 Binary files /dev/null and b/images/jumper_wires.jpg differ diff --git a/images/pslab_wave_pins.png b/images/pslab_wave_pins.png new file mode 100644 index 0000000..4fe910a Binary files /dev/null and b/images/pslab_wave_pins.png differ diff --git a/images/robotic_arm_kit.jpg b/images/robotic_arm_kit.jpg new file mode 100644 index 0000000..e539398 Binary files /dev/null and b/images/robotic_arm_kit.jpg differ diff --git a/images/sg90_servo.jpg b/images/sg90_servo.jpg new file mode 100644 index 0000000..f1841cf Binary files /dev/null and b/images/sg90_servo.jpg differ diff --git a/tutorials/roboticarm.md b/tutorials/roboticarm.md index 2dad96b..a72ebb8 100644 --- a/tutorials/roboticarm.md +++ b/tutorials/roboticarm.md @@ -1,14 +1,130 @@ -Robotic Arm Servos -====== +# Robotic Arm -Introduction to motors ----------------------- +## What is a Robotic Arm? -Servos ------- +A **Robotic arm** is a mechanical structure that mimics the movements of a human arm. It typically consists of multiple joints controlled by actuators, most commonly **servo motors**, to achieve precise angular movement. + +In the PSLab context, a robotic arm uses servo motors to perform tasks like conducting scientific experiments, lifting, rotating, or grasping. These servos are controlled via **PWM (Pulse Width Modulation)** signals. + +The **PSLab device** provides four square wave PWM outputs `SQR1`, `SQR2`, `SQR3`, and `SQR4` which allow control of up to **four servo motors**, enabling robotic arms with **up to four degrees of freedom (DoF)**. + +--- + +## How to use it + +### Requirements + +- PSLab device +- Robotic arm kit +- Jumper wires +- External power supply + +
+ PSLab Wavegen Pins + Robotic Arm Kit + Servo Motor + Jumper Wires +
+ + +### Wiring Setup + +1. Connect the **signal wires** (usually **yellow**) of the 4 servos to the PSLab device PWM outputs PINS: `SQR1`, `SQR2`, `SQR3`, and `SQR4`. +2. Connect the **power wires** (usually **red**) of all servos to the **positive terminal** of an **external power supply**. +3. Connect the **ground wires** (usually **black**) of all servos together to the **GND of the external power supply**. +4. Finally, connect the **GND of the external power supply** to the **GND pin** of the **PSLab device** to complete the common ground. + +> ⚠️ **Important:** Do not power the servos directly from the PSLab device. Use an external regulated supply capable of handling the current requirements of all servos. + + +### Performing the Experiment + +1. Open the **PSLab app** on your Phone. + +2. Navigate to **Robotic Arm**. +3. Use the interface to: + - Manually move each servo using sliders. + - Create a timeline of servo movements. + - Play, pause, or reset the timeline. + - Change Frequency. + - Save or import movements using CSV files. + + + + + + +
+ +
+ Video 1      + Video 2 +
+ + +### Timeline CSV Import/Export + +The PSLab app supports importing servo movement timelines from a **CSV file**, allowing interoperability with the **PSLab Python library**. + +#### Exporting Timeline using Python + +You can generate servo movement timelines using the `pslab-python` library and export them in CSV format for use in the PSLab app. + +Here's a minimal working example: + +```python +from pslab import ScienceLab +from pslab.external.motor import Servo, RoboticArm + +psl = ScienceLab() + +# Initialize servos on PWM outputs PINS +base = Servo("SQ1", pwm_generator=psl.pwm_generator) +shoulder = Servo("SQ2", pwm_generator=psl.pwm_generator) +elbow = Servo("SQ3", pwm_generator=psl.pwm_generator) +grip = Servo("SQ4", pwm_generator=psl.pwm_generator) + +# Create Robotic Arm instance +arm = RoboticArm([base, shoulder, elbow, grip]) + +# Define timeline: each row = [S1, S2, S3, S4] angles at 1s interval +# Use None to keep a servo at the same angle as the previous step +timeline = [ + [None, 30, 45, 10], + [90, 30, 45, None], + [180, 30, 45, None], + [45, 60, 60, 20], + [None, 60, 60, 20], + [0, 90, 90, 30], + [90, 90, 90, 30], + [180, 90, 90, 30], + [90, 45, 45, 0], + [0, 30, 30, None], +] + +# Run the timeline on the robotic arm +# This will move each servo to the specified positions sequentially at 1-second intervals +arm.run_schedule(timeline=timeline) + +# Export timeline to CSV for using in PSLab App +arm.export_timeline_to_csv( + timeline=timeline, + folderpath=r"C:\path\to\folder" +) + +# Import timeline from a CSV file +timeline = arm.import_timeline_from_csv(filepath=r"\path\to\folder\filename.csv") + +``` + +### Observations + +- Each servo rotates to the specified angle. +- Timeline playback, with position updates every 1 second, allows synchronized movement across all joints. + +### Applications + +- Pick-and-place mechanisms +- Educational demos in robotics and automation -Experiment: How to move servos with PSLab ------------------------------------------ -Experiment: The Robot Arm Kit ------------------------------ \ No newline at end of file