ENGR 2110 - Principles of Engineering

Profs. Millner, Faas, Minch, & Reifel

Fall 2018

Lab 2 - Due before class Tues., 9/25

Lab 2 - DIY 3D Scanner


1) Build and program a rudimentary 3D scanner using a pan/tilt mechanism

2) Scan an object of known, well-defined geometry

3) Visualize the output from your scanner


The first lab should have gotten you comfortable with (or at least aware of) how to read and write digital signals, how to read and convert analog signals, and how to use an analog input to change the digital behavior of your circuit.

The purpose of this lab is to introduce sensors and actuators. Sensors are devices that transduce a physical quantity in the world (distance, force, pressure, chemical concentrations, etc.) into a different, often more easily measurable, physical quantity like voltage. Actuators are duals to sensors in that they transform one form of energy (hydraulic pressure, chemical energy in gasoline, electrical potential, etc.) into mechanical work.

This lab will make use of an infrared distance sensor and two hobby servo motors. An infrared distance sensor is an infrared emitter (LED) paired with an infrared detector (photodiode). The detector measures the intensity of the IR light reflected off of an object in its field of view. The output of the sensor is an analog voltage. A hobby servo motor is more than just a motor; it’s a DC motor connected to a potentiometer (to measure the shaft angle), hardware proportional-integral-derivative (PID) controller (to perform position control), and a gear train (to increase torque and decrease speed). A hobby servo is controlled using a square wave form that is pulsed at a fixed frequency. The time that the waveform signal is set to “on” determines what the position of the shaft should be. This scheme is called “pulse width modulation” (PWM) and the percentage of “on” time during the period is called the “duty cycle”. Most hobby servos use a pulse width of between 1ms and 2ms (sometimes the range can be as wide as 0.8ms to 2.2ms).


Create a pan/tilt mechanism using the servos and sensor provided for you that is controlled by an Arduino. Transmit servo angle and distance information from your sensor to your laptop for storage and, ultimately, visualization. Using a software package of your choice (MATLAB, Python, JavaScript, etc.) create a 3D visual representation of an object of known, well-defined geometry.

Suggested Steps

  1. Connect your sensor to the appropriate pins on the arduino and verify that it works using the “AnalogInput” example from the Arduino development environment.
  2. Test that serial connection between your laptop and the Arduino can relay sensor data using the “AnalogInOutSerial” example in the Arduino IDE. We have also created a sample sketch that sends data back to the laptop after receiving commands from a  sample Python script. (The teaching team will provide support for students understanding and building upon the samples listed above; additionally, we are linking unsupported options you can learn from on your own: sample Matlab script, sample sketch 2, sample Python script 2.)
  3. Test the functionality of your servos using the  “Sweep” example in the Arduino IDE (under “Servo”).
  4. Calibrate your distance sensor. Calibration is the process of getting a set of readings for known distances and determining the mathematical relationship between physical distance and the sensor voltage reading.
  5. Test your calibration with distances that were not used as part of the calibration procedure.
  6. Pick a letter that represents an initial of one of your team members, and cut that letter out of a large sheet of cardboard, foamcore, or pink foam. Create a stand or a base plate for the letter that enables it to stand freely without you having to hold it.
  7. Mechanically mount your sensor to a single servo. [1]
  8. Create a program that sweeps the sensor across the letter and reports distances and the servo angle using serial output from the Arduino.
  9. Create a graph of the 2D, top-down representation of the letter along that line.
  1. Update 2018_09_20: if you are plotting the graph after this date, we recommend that you scan a single horizontal slice of your object and represent the distances on the graph in X,Y cartesian coordinates. If you have already done this step, you may submit what you have and will not be penalized, this instruction is for clarifying confusion.
  1. Create the pan/tilt mechanism and program it to sweep the entire face of your letter and return distance measurements and both servo angles.

Bill of Materials (BOM):

Click Here to view opt-in alternative steps that a few students can follow for this  assignment if they want to experiment with a possible new lab 2 process that NINJAs and instructors are just beginning to explore for 2019 (a process that is still quite buggy).

Lab Report

Your lab report should include the following elements:

  1. A description of the process you used to test your sensor
  2. A calibration plot depicting analog voltage reading vs. actual distance
  3. An error plot showing predicted distance and actual distance for distances not included in your calibration routine
  4. An explanation of your calibration function
  5. An image of your setup for the 1 servo scan of your letter and the data depicting the top view
  6. A photo of your setup for the 2 servo apparatus and some visualization of the 3D data resulting from your scan (a plot, an image, a video, etc)
  7. All source code

Please submit your report as a pdf attachment named lab2_<partner1_last_name>_<partner2_last_name>.pdf  to poe.submit@gmail.com and read the Lab Report Style Guide carefully before writing your lab report.

[1] If you have not yet been trained on the laser cutter or 3D printers, this might be a good time to sign up for training or talk to Rapid Prototyping NINJAs.