Prelab

1. Diagram with your intended connections between the motor drivers, Artemis, and battery (with specific pin numbers)

wire

2. Battery discussion

We use seperate batteries to power artemis and the motors in order to reduce EMI between controller and actuator.

Lab Tasks

1. Picture of your setup with power supply and oscilloscope hookup

Picture of power supply:

dc

Oscilloscope hookup:

spin

2. Power supply setting discussion

I use the voltage generator to ouput 3.7V DC power supply to the motor drivers, in order to keep the same as batteries.

3. Include the code snippet for your analogWrite code that tests the motor drivers

void loop() {
  // go straight
  analogWrite(6, 0);
  analogWrite(7, 35);

  analogWrite(11, 0);
  analogWrite(12, 60);
  delay(1);
}

4. Image of your oscilloscope

osci

video when adjusting pwm output:

5. Short video of wheels spinning as expected (including code snippet it’s running on)

6. Short video of both wheels spinning (with battery driving the motor drivers)

7. Picture of all the components secured in the car

comp

8. Lower limit PWM value discussion

The lowest pwm value for left wheels is 50;

The lowest pwm avalue for right wheels is 28.

9. Calibration demonstration (discussion, video, code, pictures as needed)

I use the code below to calibrate the original output (ranging from 0 ~ 1000) to the new output for pwm (ranging from 0 ~ 255)

int ctrl_pwm_map(int control, int ctrl_min, int ctrl_max, int pwm_min, int pwm_max) {
  int pwm = (control - ctrl_min) * (pwm_max - pwm_min) / (ctrl_max - ctrl_min) + pwm_min;
  return pwm;
}

left_pwm = ctrl_pwm_map(control, 0, 1000, 55, 255);
right_pwm = ctrl_pwm_map(control, 0, 1000, 28, 255);

10. Open loop code and video

11. (5000) analogWrite frequency discussion (include screenshots and code)

The frequency of analogWrite is fast enough for the motors.

Manually configuring timers to generate a faster PWM signal can:

  1. spare more resource for CPU to carray out other time consuming tasks
  2. increase the control accuracy for motors

12. (5000) Lowest PWM value speed (once in motion) discussion (include videos where appropriate)

Condition Left Motor Right Motor
start from rest 50 28
move when running 45 24