16.632: Intro to Autonomous Machines
- Outline
- 1. Basics of Arduino and Breadboards
- 2. Limit Switches, Serial Communication, and Randomization
- 3. Analog Sensors and Interpolation
- 4. Career Lecture
- 5. Servo Motors and State Machines
- 6. Sensor and Motor Shields
- 9. Line Tracking Sensors (nice)
- 10. Bang-Bang Controller and Motor Behavior
- 12. Bang-Bang vs. PID Controllers
- 13. PID Controller Calibration
- 16. Inertial Measurement Unit (IMU)
- 19. Interrupt Service Routines and Encoders
- 20. Physics and Non-Blocking Code
- 22. Maze
- 23. Mechanics and Materials Review
From the course catalog: Experiential seminar provides an introduction to the fundamental aspects of robust autonomous machines that includes an overall systems/component-level overview. Projects involve hands-on investigations with a variety of sensors and completely functioning, small-scale autonomous machines utilized for in-class implementation/testing of control algorithms. Uses Arduino.
Outline
(Generated by ChatGPT)
1. Basics of Arduino and Breadboards
- Sensors: Output either analog (continuous) or discrete (HIGH/LOW) data.
- Arduino Basics:
- Key functions:
setup()
,loop()
,pinMode()
,digitalRead()
,digitalWrite()
,delay()
,millis()
. - Inputs and outputs: Use
INPUT_PULLUP
to reverse signal logic (0 = HIGH, 1 = LOW).
- Key functions:
- Breadboard Overview:
- Red (+) columns = 5 V, black (-) columns = ground.
- Split rows for circuit connections.
2. Limit Switches, Serial Communication, and Randomization
- Limit Switches: Use
INPUT_PULLUP
for toggling HIGH/LOW states. - Serial Communication:
- Functions:
Serial.begin(speed)
,Serial.print()
, andSerial.println()
. - Float precision formatting:
Serial.print(x, 2)
.
- Functions:
- Random Numbers:
random(a, b)
generates integers in [a, b-1].- Seed with
randomSeed(x)
for varied outputs.
3. Analog Sensors and Interpolation
- Analog Inputs:
- Pins A0-A5 for reading sensor voltages.
- Function:
analogRead(pin)
returns values (0–1023).
- Sensors:
- Photoresistor: Resistance decreases with increased light.
- Force Sensor: Resistance changes based on applied force.
- Data Interpretation: Use plots and interpolation (e.g., linear) for translating sensor outputs to meaningful values.
4. Career Lecture
- Resume Writing:
- Highlight interpersonal, conceptual, and technical skills.
- Use PAR (Problem, Action, Result) statements for experiences.
- Coursework and class projects can be included as experiences.
- Customize the resume with keywords from the job description.
- Cover Letters:
- Personalize using common connections or events you attended.
- Write a draft yourself before refining with tools like ChatGPT.
- Career Fair Prep:
- Define goals: industries of interest, skills to showcase.
- Research companies and prepare an elevator pitch with questions.
- Cold Emailing:
- Send a pitch and follow up after 2 weeks if no response.
5. Servo Motors and State Machines
- Servo Motors:
- Rotate within 180° or continuously, using three wires (VCC, ground, signal).
- Controlled via the Arduino Servo library (disables analog pins 9/10).
- Key functions:
servo.attach(pin)
andservo.write(position)
.
- State Machines:
- Framework for programming actions based on specific sensor states or values.
6. Sensor and Motor Shields
- Sensor Shield:
- Simplifies connections for sensors, servos, and modules to the Arduino.
- Custom DC Motor Shield:
- Used to control front wheels of cars.
- Utilizes pulse-width modulation (PWM) to adjust analog signals via digital outputs.
9. Line Tracking Sensors (nice)
- Line Tracking Sensor:
- Uses an infrared emitter and receiver to differentiate light and dark.
- Analog output:
0
(black) to1000
(white); optimal sensor distance is 1–5 cm.
- Calibration Process:
- Place each of the 5 sensors over the black track and record readings.
- Determine min/max values for each sensor, normalize, and constrain readings to [0, 1].
- Line Tracking Method:
- Black readings = mass of weight
1
; white readings = mass of weight0
. - Use the center of gravity of these masses to estimate line location.
- Black readings = mass of weight
10. Bang-Bang Controller and Motor Behavior
- Bang-Bang Controller:
- Simplest controller type (e.g., a heater): toggles on/off based on a setpoint.
- Motor Observations:
- Programmed motor speeds may yield varying RPMs due to external factors.
- Line Tracking Failures:
- Ensure
I_tot
(intensity total) is not zero; add a small bias to prevent loss of signal.
- Ensure
12. Bang-Bang vs. PID Controllers
- Bang-Bang Line Tracking:
- Oscillates around a setpoint, requiring significant trial and error.
- PID Controller:
- Uses error between setpoint and sensor value to adjust left and right turn speeds automatically.
- Separate PID controllers for each wheel (e.g.,
KP_left
,KP_right
). - Derivative term can cause “jerky” behavior if tuned incorrectly; it may not always be necessary.
13. PID Controller Calibration
- Calibration Steps:
- Set integral and derivative gains to zero, then adjust proportional gain to match Bang-Bang behavior.
- Add derivative gain to prevent overshooting the line.
- Add integral gain to prevent slow off-center movement.
- Debugging: Adjust the setpoint for testing; the controller should work regardless of the setpoint.
16. Inertial Measurement Unit (IMU)
- IMU Overview:
- Measures roll, pitch, yaw, rotation velocity, and acceleration.
- Uses the Adafruit sensor library for data reading.
- Angle Outputs:
- Default sensor outputs are in an unconventional orientation.
- Remap values using the
atan2
function to standardize them to the range[-π, π]
.
19. Interrupt Service Routines and Encoders
- Interrupt Service Routines (ISR):
- Short code segments triggered by interrupts, executed alongside the main program.
- Incremental Encoders:
- Count state changes (HIGH/LOW) for rotation tracking.
- Quadrature Method: Uses two offset sensors detecting magnetic fields in a square wave pattern to determine rotation direction (CW/CCW) and velocity.
20. Physics and Non-Blocking Code
- Physics Calculations:
- Distance derived as a function of echo time.
- Blocking vs. Non-Blocking Code:
- Prefer non-blocking code for smoother operation.
22. Maze
- Maze Setup:
- Entrance at one of the 4 bottom squares, starting just outside the maze.
- Exit at one of the 4 top squares, potentially with a small entrance ramp.
- I combined the A* pathfinding algorithm with an ultrasonic sensor to rock this challenge!
23. Mechanics and Materials Review
- Torque and Moments:
- Definition: Torque is equivalent to a moment (or couple) in Mechanical Engineering.
- Moment Formula: M = rF, where abs(M) = abs(r) abs(F) sin(phi).
- Use the right-hand rule to determine the direction of the moment vector.
- Statics Basics:
- Statics involves systems with no acceleration; focus is on balancing forces and moments.
- Tools like CAD SolidWorks or Fusion 360 automate stress calculations; understanding concepts is key.
- Problem-Solving Tips:
- Draw clear and detailed diagrams, similar to physics problems.
- Moments need to be taken about a specific point to analyze rotational effects.
- Static Equilibrium:
- Conditions: (\Sigma \vec{F} = 0), (\Sigma \vec{M} = 0).
- Break moments into components and solve using 6 equations derived from these conditions.
- Common axes of motion include:
- Roll: Rotation along a table.
- Pitch: Forward/backward tilt.
- Yaw: Spinning on a surface.
- Loading Conditions:
- Forces: Point loads.
- Distributed Loads: Force per unit length.
- Create free-body diagrams by abstracting the system into simplified forces and moments.