Due: 2:00 p.m. on the next Wednesday or Thursday.
- Report Format: Submit a formal, typed lab report in PDF format. Handwritten lab reports will not be accepted. Hand-drawn circuit diagrams will not be accepted; draw every schematic with software (see Software at the end of this manual). Include screenshots, code, and simulation or measurement results where specified.
- AI Policy: The use of any AI tool, including a large language model (LLM), to write, generate, debug, or modify code or any portion of the lab report is prohibited unless the course instructor grants explicit permission in advance. A teaching assistant (TA) cannot grant permission to use AI tools.
By signing below, I acknowledge that I have read and understood the policies and instructions above and agree to follow them.
Student Name (print):
Student Signature: Date:
Tasks
You have used simple logic sequences to control LEDs and pulse-width modulation (PWM) to control a DC motor. In this lab, you will control the direction and speed of a stepper motor by changing the polarities of its coil sets in a defined sequence. You will also control a servo motor by varying the pulse width at a fixed 50 Hz frame rate. Include relevant screenshots, photographs, and videos in your report, and add descriptive comments to your programs. Use the terminal to create a directory for your lab files.
- Read the datasheets for the NEMA 17 stepper motor and motor-driver chip. Identify the motor-driver pins and the stepper motor’s four colored wires. Draw a schematic showing how you plan to connect the driver, motor, Raspberry Pi, and power supply. Show your design to the course instructor or a TA.
- Create full-step and half-step logic tables for both clockwise and counterclockwise rotation. Show the logic tables to the course instructor or a TA.
- Construct the circuit you designed to run the stepper motor. Obtain approval from the course instructor or a TA before applying power. Your code must be able to:
- turn the motor clockwise for at least two full rotations using both full-step and half-step sequences;
- turn the motor counterclockwise for at least two full rotations using both full-step and half-step sequences; and
- report the total runtime, number of revolutions, step period, step frequency, revolution period, rotation angle per step, and total number of steps. Compare the reported values with your observations.
Course Instructor or TA Signature:
Date and Time:
- Connect the MG996R servo motor to the Raspberry Pi. Attach the two-pronged servo horn to the output gear. Do not rotate it by force; forced rotation can damage the servo. To change the horn orientation, remove it and reinstall it at the desired angle. Power the servo from its own regulated 5–6 V supply, and connect that supply's ground to the Pi's ground. Choose a zero angle and mark it, then write a program that moves the horn 30° from that mark. Check the angle with a protractor.
Course Instructor or TA Signature:
Date and Time:
Extra Credit (up to +6 points)
These tasks are optional and meant for students who finish the required tasks early. The course instructor and TAs will not provide any help with them: no hints, no debugging, and no checking of your design, wiring or code. Do them entirely by yourself.
Finish every required task and get it signed off first. A TA will sign off a finished extra-credit task only when it works. A TA will still stop any setup that could damage the equipment or the Raspberry Pi. Points count only for a task that is signed off and written up in your report, with an error analysis where it applies, as for every task.
- Servo calibration and input checking (+6 points). Modify your code so that the servo moves through the full range it can actually reach. Start near the center and move toward each end in small steps. Back off as soon as the horn stops moving or the servo starts to buzz or strain. Measure the angular range and compare it with the datasheet. Create a table of duty cycle versus rotation angle, determine a fitting formula that predicts angle from duty cycle, and evaluate its accuracy. Finally, modify your code to accept a valid angle as input and reject values outside the permitted range.
Course Instructor or TA Signature:
Date and Time:
Hardware Reference
The lab motor's lead colors are not in either stepper datasheet; use the figure below, and confirm the coil pairs with a DMM before connecting anything. The Lecture 05 notes explain each part in detail.



| Part | Limit | Source |
|---|---|---|
| DRV8833 motor supply VM | 2.7–10.8 V | TI DRV8833 data sheet, §6.3 |
| DRV8833 current per coil | Up to 1.5 A RMS in the PWP and RTY packages, 0.5 A RMS in the PW; 2 A peak. The real limit depends on your board's package and cooling. | TI DRV8833 data sheet, §1 |
| DRV8833 logic inputs | 3.3 V GPIO is a valid high (≥ 2 V) | TI DRV8833 data sheet, §6.5 |
| MG996R supply | Regulated 5–6 V, from a supply that can deliver your servo's peak current | Tower Pro lists 4.8–6.6 V; the reference sheet you were given says otherwise. See Lecture 5 §9.6. |
| MG996R signal | 50 Hz frame (20 ms period) | Tower Pro MG996R data sheet |
Submission Reminder
- Your stepper-motor connection schematic and the full-step/half-step logic tables.
- Your complete, commented Python scripts for both the stepper and servo motors.
- The reported runtime, number of revolutions, step period, step frequency, revolution period, rotation angle per step, and total number of steps for the stepper motor, compared with your observations.
- An error analysis for every task where it applies, including extra-credit tasks: the uncertainty of each measured or calculated value, its main sources of error, and a comparison with the expected, simulated, or datasheet value.
- A discussion of any challenges encountered and how you overcame them.
- If you did the extra credit (Task 5): the measured angular range compared with the datasheet, the duty-cycle-vs-angle table for the servo, your fitting formula and an assessment of its accuracy, and the angle-input program.
Draw every circuit diagram with software; hand-drawn circuit diagrams will not be accepted. We recommend the free draw.io; the course’s Drawing Circuit Diagrams page shows how to set it up. If a component has no symbol of its own, use the closest one and label it clearly.
Where a task asks for a simulation: the web version of Multisim is no longer available. If you have a Windows computer, you can install the offline (desktop) version of Multisim; ask a TA for the serial number to install it. Otherwise, feel free to use any SPICE-based simulation tool, such as LTspice or ngspice.