Day 6: (Thu Jul 11) System Engineering Practice

Notes for 2019-07-11. See also the Calendar.

Agenda

In-class activities:

  1. Review

    1. Brief review of basic electronics.
    2. Brief walkthrough of actuators: solenoid, DC motor, hobby servo.
    3. Brief walkthrough of Pinball Arduino Mega Shield
    4. Brief demo of rocker example.
  2. Design and Build

    The goal is to get an interesting programmed behavior out of a simple structure and an actuator.

    1. We will pair you up.
    2. Assemble a rocker using the provided parts.
    3. Run the sample sketch below, adjusting the pin numbers to match your wiring. Related exercise: Servo Sweep.
    4. Use the serial interface to tune the parameters. Try both with and without a pinball.
    5. Adjust the sketch code if needed.
    6. Once you find an movement you like, document on video.
  3. Exploration

    There are a number of possible followups. Here are some suggested starting points:

    1. Try different uses of the servo: it could be flipped, use a different lever, or have mass added for an inertial principle of actuation.
    2. Redesign and recut the wooden parts. E.g. adjust the curvatures or center of mass.
    3. Add a photosensor to the device: Photointerruptor circuits. Add code to reliably detect the ball crossing the midline and report the timing.
    4. Add an accelerometer (ADXL335) to the structure.
    5. Add a feedback loop to actuate the servo based on the photosensor or accelerometer data.
  4. Design meeting: for the last 45 minutes, we’ll discuss the game concepts again, with the goal of settling on a main concept and a candidate short list of features (still to be revised).

Rocker Design Resources

The rocker CAD files are in rocker-example.zip.

../_images/rocker-isometric.PNG

Lecture code samples

Rocking the Rocker

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// 1. rock the toy with a servo
// 2. demonstrate the Servo library

#include <Servo.h>

const int ARDUINO_LED = 13;

const int SERVO1_PIN = 23;  // on the Mega Pinball Shield

const int PHOTO1_PIN = A0;  // on the Mega Pinball Shield

const int TILT_X_PIN = A8;  // on the Mega Pinball Shield
const int TILT_Y_PIN = A9;  // on the Mega Pinball Shield
const int TILT_Z_PIN = A10; // on the Mega Pinball Shield 

Servo rocker_servo;

void setup()
{
  pinMode(ARDUINO_LED, OUTPUT);
  rocker_servo.attach(SERVO1_PIN);
  Serial.begin(115200);
}

int lower = 60;
int upper = 80;
int pause1 = 100;
int pause2 = 500;

void loop()
{
  digitalWrite(ARDUINO_LED, HIGH);

  rocker_servo.write(lower);
  delay(pause1);

  digitalWrite(ARDUINO_LED, LOW);  
  rocker_servo.write(upper);
  delay(pause2);

  int photo1 = analogRead(PHOTO1_PIN);
  int tilt_x = analogRead(TILT_X_PIN);
  int tilt_y = analogRead(TILT_Y_PIN);
  int tilt_z = analogRead(TILT_Z_PIN);

  Serial.print("Photo1: "); Serial.print(photo1); Serial.print(" ");
  
  Serial.print("Servo lower upper pause1 pause2: ");
  Serial.print(lower); Serial.print(" ");
  Serial.print(upper); Serial.print(" ");
  Serial.print(pause1); Serial.print(" ");
  Serial.print(pause2); Serial.print(" ");
      
  Serial.print("Tilt XYZ: ");
  Serial.print(tilt_x); Serial.print(" ");
  Serial.print(tilt_y); Serial.print(" ");
  Serial.println(tilt_z);

  if (Serial.available() > 0) {
    lower = Serial.parseInt();
    upper = Serial.parseInt();
    pause1 = Serial.parseInt();
    pause2 = Serial.parseInt();
    while(Serial.available() > 0) Serial.read();
  } 
}