Bev Facey Community High

ELT1130: Robotics 1

Students apply the fundamentals of robotics systems and basic robotics functions.

Safety Reminder

Robotics systems include moving parts and electrical power. Always:

Theory

Answer the following questions on paper.

  1. Identify and explain the main subsystems of a robot:
    • Power system
    • Controller (microcontroller or processor)
    • Sensors
    • Actuators
    • Structure/chassis
  2. Describe how sensors provide inputs to a robot.
  3. Explain how a controller processes these inputs.
  4. Describe how actuators create outputs.
  5. Draw a block diagram showing signal flow in a simple robot.
  6. Choose three different sensors commonly used in robotics (e.g., ultrasonic, line sensor, button, light sensor) and explain:
    • What each sensor measures
    • What kind of signal it produces
    • How the robot can use that information
  7. How are DC motors different from servos?
  8. Why motor drivers are needed between controllers and motors?
  9. Explain what could happen if:
    • A motor stalls
    • A sensor is miswired
    • Power polarity is reversed
  10. Identify two real-world robotic applications (industry, healthcare, transportation, exploration, etc.) and explain what sensors and actuators those robots likely use.

Practice - Object-Tracking Webcam

In this project, you are building a system with two main “brains” that talk to each other:

Materials

Assembling the System

Standard hobby servos (like the common blue SG90 micro servos) have three wires. They are usually color-coded like this:

  1. Connect the Grounds: Connect the Brown/Black wires from both servos to any of the GND pins on your microcontroller.
  2. Connect the Power: Connect the Red wires from both servos to the VBUS pin. This pin takes the 5V directly from your computer’s USB port.
  3. Connect the Signals: Connect the Yellow/Orange wire from each servo to a different General Purpose Input/Output (GPIO) pin. (For example, GP15).
  4. Use a USB cable to connect the microcontroller to the computer.
  5. Connect the USB webcam to your computer.

Note: Moving two servos at the same time can use a lot of electrical current. If your microcontroller suddenly disconnects or restarts when the servos move, you will need to power the servos using a separate external 5V source. Remember to connect the ground of the battery pack to the ground of the microcontroller.

Programming the Muscle

Your first goal is to make the Pico move the servos based on text commands. You will use Thonny and Google Gemini for this.

  1. Initialize the Hardware: Set up your two servo pins using Pulse Width Modulation (PWM). You’ll need to research how to set the correct frequency (usually 50Hz for servos) and duty cycle to move them.
  2. Create a Command Listener: Write a loop that constantly checks for incoming data over the USB serial connection. You can use standard input reading commands (like reading a line of text) in MicroPython.
  3. Parse the Data: Decide on a format for your commands. For example, your computer might send “X90 Y45\n”. Your Pico needs to read that string, split it up, and understand that the pan servo goes to 90 degrees and the tilt servo goes to 45 degrees.
  4. Move the Servos: Map those numbers to the correct PWM duty cycles and update the servos.
  5. Test: Before connecting the computer’s Python script, use Thonny’s shell to manually type in commands (like “X90 Y90”) and press Enter to see if your servos move correctly.

Programming the Brain

Write (or vibe-code) a Python script on your computer to process the video feed.

  1. Capture the Video: Use OpenCV to access your webcam and start reading frames in a continuous while loop.
  2. Find the Object: Look up OpenCV’s Color Masking (converting the image to HSV color space and finding contours).
  3. Calculate the Center: Once OpenCV finds your object, it will give you a bounding box (X, Y, Width, Height). You need to calculate the exact (x, y) center coordinate of that box.

Communicating from the Brain

The computer needs to tell the microcontroller what to do based on where the object is.

  1. Open a Serial Connection: Use the pyserial library in Python to open a connection to the COM port (Windows) or /dev/tty port (Mac/Linux) that your Pico is plugged into.
  2. Calculate the Error: Find the center of your webcam’s overall video frame (e.g., if your camera is 640x480, the center is 320, 240). Compare the object’s center to the frame’s center. If the object is at X=400, it’s too far to the right!
  3. Generate the Command: Write logic that says: “If the object is too far right, decrease the pan angle. If it’s too high, increase the tilt angle.”
  4. Send the Command: Format your new angles into the string format you decided on in Step 1 (e.g., “X85 Y50\n”) and send it over the serial port.

Tuning and Refinement

Your camera will probably track the object, but it might jitter wildly or overshoot! Welcome to the world of control systems.

Demonstration

Once you are satisfied with how your system performs, demonstrate it to some classmates and your teacher.

Reflection

  1. How does this robot arm resemble industrial automation systems or commercially available products?
  2. What skills here apply to CNC machines or drones?
  3. What was challenging?
  4. What worked well?
  5. Explain how the skills learned here prepare you for:
    • advanced robotics learning
    • future robotics or technology careers