FastRobots

ECE4160/5160-MAE 4190/5190: Fast Robots course, offered at Cornell University in Spring 2024

This project is maintained by FastRobotsCornell

Fast Robots @ Cornell

Return to main page

Lab 4: Motors and Open Loop Control

Objective

The purpose of this lab is for you to change from manual to open loop control of the car. At the end of this lab, your car should be able to execute a pre-programmed series of moves, using the Artemis board and two dual motor drivers.

Parts Required

Prelab

If you have never used and osciloiscope before, or would like a refresher, please watch this tutorial by Dr. Kirstin Petersen for reference.

Check out the documentation and the datasheet for the dual motor driver.

Note that to deliver enough current for our robot to be fast, we will parallel-couple the two inputs and outputs on each dual motor driver, essentially using two channels to drive each motor. This means that we can deliver twice the average current without overheating the chip. While it is a bad idea to parallel couple motor drivers from separate ICs because their timing might differ slightly, you can often do it when both motor drivers exist on the same chip with the same clock circuitry.
In your lab write-up, discuss/show how you decide to hook up/place the motor drivers.

Instructions

  1. Connect the necessary power and signal inputs to one dual motor driver (where inputs/outputs are hooked up in parallel as discussed in lecture) from the Artemis.
    • For now, keep the motor driver (VIN) powered from an external power supply with a controllable current limit; this will make debugging easier.
    • What are reasonable settings for the power supply?
  2. Use analogWrite commands to generate PWM signals and show (using an oscilloscope) that you can regulate the power on the motor driver output.

  3. Take your car apart!
    • Unscrew and remove the top (blue) shell from your car. You may have to cut the wires for the chassis LEDs (we will not be using them in this class). Don’t loose the screws!!
    • Locate and unmount the control PCB and cut wires to the motors and the battery connector as close to the board as possible.
  4. Place your car on its side, such that the spinning wheels are elevated, and show that you can run the motor in both directions.
    • Keep the motor driver powered on an external power supply for now, but remember to connect all grounds in your circuit.
  5. Power the motor driver from the 850mAh battery instead of the power supply (double check color codes before you plug it in), and make sure your code works when the circuit is fully battery powered.

  6. Repeat the process for the second motor and motor driver. One 850mAh battery should be enough to power both motors.

  7. Install everything inside your car chassis, and try running the car on the ground.
    • Remember, the car may flip, so try to avoid having components that stick out beyond the wheels.
    • Also, the car is very fast, so test it in the hallway and add a timer in code so that it stops automatically after a short amount of time. That way you don’t have to try to catch it when it gets away from you!
    • Here is an example of a car with everything hooked up (note that we did not use QWIIC connectors in this one). Remember that the implementation details are entirely up to you.

  8. Explore the lower limit in PWM value for which the robot moves forward and on-axis turns while on the ground; note it may require slightly more power to start from rest compared to when it is running.

  9. If your motors do not spin at the same rate, you will need to implement a calibration factor. To demonstrate that your robot can move in a fairly straight line, record a video of your robot following a straight line (e.g. a piece of tape) for at least 2m/6ft.
    • It may be helpful to note that each of the vinyl tiles in the lab is 1-by-1 foot.
    • The robot should start centered on the line, and still partially overlap with the line at the end.
  10. Demonstrate open loop, untethered control of your robot - add in some turns.

Additional tasks for 5000-level students

  1. Consider what frequency analogWrite generates. Is this adequately fast for these motors? Can you think of any benefits to manually configuring the timers to generate a faster PWM signal?

  2. Relating to task 8 above, try to (experimentally) figure out not just at what PWM value the robot starts moving (forward and on-axis turns), but also the lowest PWM value at which you can keep the robot running once it is in motion. How quickly can you have the robot settle at its slowest speed? (First program a value that overcomes static friction and gets the robot moving, then a value that keeps it moving as slowly as possible.)

Write-up

Word Limit: < 800 words

Webpage Sections

This is not a strict requirement, but may be helpful in understanding what should be included in your webpage. It also helps with the flow of your report to show your understanding to the lab graders.

  1. Prelab
    • Diagram with your intended connections between the motor drivers, Artemis, and battery (with specific pin numbers)
    • Battery discussion
  2. Lab Tasks
    • Picture of your setup with power supply and oscilloscope hookup
    • Power supply setting discussion
    • Include the code snippet for your analogWrite code that tests the motor drivers
    • Image of your oscilloscope
    • Short video of wheels spinning as expected (including code snippet it’s running on)
    • Short video of both wheels spinning (with battery driving the motor drivers)
    • Picture of all the components secured in the car
      • Consider labeling your picture if you can’t see all the components
    • Lower limit PWM value discussion
    • Calibration demonstration (discussion, video, code, pictures as needed)
    • Open loop code and video
    • (5000) analogWrite frequency discussion (include screenshots and code)
    • (5000) Lowest PWM value speed (once in motion) discussion (include videos where appropriate)

Add code (consider using GitHub Gists) where you think is relevant (DO NOT paste your entire code).