STEAM DISCOVERY LAB
  • About
  • Tools
  • Projects
  • Resources
  • About
  • Tools
  • Projects
  • Resources
Search

Simple Proportion Controller

Lesson Objectives:
  1. Students will build a simple LEGO car.
  2. Students will learn that a simple proportion controller relates two variables linearly.
  3. Students will learn how to program this on the EV3 IDE.

​Materials:
  • 2 motors
  • EV3 brick with Wifi dongle and SD card (you should have access to the EV3 IDE)
  • Ultrasonic Sensor
  • Any other LEGO parts you need to build a car
What is a Simple Proportion Controller?

Let's say you are riding a bike when you see a wall in front of you and you decide that you want to stop 10 feet in front of the wall. If you were using a simple proportion controller, you would begin to slow down gradually as you approached the 10 feet mark rather than slam the brakes at once.

In theory, this works when moving backwards as well. If you ended up stopping 5 feet in front of the wall, you would pedal backwards fast and then slow down as you reached the 10 feet mark before finally coming to a stop.

When we build our LEGO car, we will program it so that it will maintain a certain distance in front of itself, and if there is an obstacle in front of it, it will either keep moving forward or backwards until it reaches its safe distance, or just stop if it is at the safe distance.
Let's Get Started!
​

Go ahead and make a car of your design that incorporates the EV3, ultrasonic sensor, and the two motors. Run IDE on the brick and load up the IDE on your computer by entering the IP number of the brick on a search tab.

First, we want to initialize the ultrasonic sensor and the motors we will be using. We also want to assign our safe distance to a variable so that this can be changed easily in the future, as well as a constant of proportionality (k), which determines how fast the car moves relative to the distance reading from the ultrasonic sensor. 

Since we want the car to move faster when it is further away from the obstacle and slower as it gets closer, we must set the speed of the motors equal to the distance reading multiplied by the constant of proportionality (k). If we want the car to move faster in general, we can just increase the value of k.

All that is left is to tell the car when to move and when to stop. There are three different cases to consider:
  1. If the obstacle is farther than the safe distance, keep moving forward at a constant speed.
  2. If the obstacle is closer than the safe distance, move backwards at a constant speed.
  3. Otherwise, just stay still.

An example of the code that was outlined above is shown here. Feel free to use this as a guide if you run into errors, but please try and write the code yourself with the help of the snippets provided on the IDE.
Picture
Picture
200 Boston Ave, Medford, MA 02155
steamdiscoverylab@gmail.com
Center for Engineering Education and Outreach
​Tufts University
About
Tools
Projects
Resources
​
Contact
LEGO®, the LEGO® logo, the Brick, MINDSTORMS®, and the Minifigure are trademarks of ©The LEGO® Group. On some parts of this site  you will get access to so-called “developer software”, which offers documentation on different ways to operate the LEGO® Education SPIKE™ Prime Hub and technology. Whatever use you make of the developer software, bear in mind that the results are not experiences that the LEGO Group endorses, is with or will be liable for. No rights in or to trademarks of the LEGO Group are implied or given, and you may not apply to or register any protection anywhere in the world for intellectual property or industrial rights or similar in respect of any developer software, derivative or other result achieved through its use. The developer software is made available “as is” and, to the extent possible, no warranties or representations are implied or given in relation to it by the LEGO Group. It’s your responsibility to ensure all uses that you make and enable others to make comply with all applicable laws and best practices. By accessing the developer software, you acknowledge that the terms and conditions set out above and in LEGO Education’s terms of use for SPIKE Prime apply.
  • About
  • Tools
  • Projects
  • Resources