Acceleration Due to Gravity

With Lego EV3 & Python

Group Size 3-4

Grade Level 8-11

Time required 3-4 hrs

The aim of the lesson is to research experientially topics related to the gravitational acceleration g, learned theoretically during physics class, and try to answer questions that arise, such as what about g for different heights or for heavier/lighter objects. You will execute an experiment that involves the construction of a Lego EV3 drop tower equipped with suitable sensors and programmed in Python language for calculating g affecting a ball in free fall. In the process of experiment you’ll have to remember and apply mathematics notions, such as that of slope.

We would like to show you that Robotics can be very helpful when used to collect data in physics experiments, giving you the motivation to try Robotics to other physics concepts, as well. Robotics for measuring g can provide an accurate and reliable result. Times less than 1 sec are difficult to measure with a conventional clock. Synchronization of leaving a ball and thereby counting falling time is extremely difficult to obtain.

Prerequisite

Materials List

Each group of students needs:

  • Lego Mindstorms Education EV3 Base/Education set

  • Computer with Python 3 installed

  • Two or three balls of similar shape and different weights

  • Calculator

  • Meter stick

What students should know before?

Definitions of the concepts: Forces, Gravity, Gravitational acceleration g, Universal law of gravitation, Free falling objects. For this reason, they can study 2 types of learning resources: interactive videos and text material.

They can watch interactive videos at home from the Edpuzzle site (they first create a student account on this platform with their details). As they watch each video, they will answer relevant questions that are embedded in appropriate points in the video. This is the flipped learning model.

They can watch at home the following videos:

  • Introduction to Free-Fall and the Acceleration due to Gravity (Interactive video)

  • Acceleration Due to Gravity tutorial (interactive video)

  • The Acceleration due to Gravity (interactive video)

  • Calculating Acceleration Due to Gravity (g) (interactive video)

  • Acceleration Due to Gravity

They can also study at home the following text material:

  • Introduction to the concept and equations of gravity

  • Newton’s law of gravitational acceleration

Preparing For This Experiment:

First Steps:

  • The LEGO Mindstorm EV3 Robot that coincides with this experiment comes from building specific sections found in the LEGO Mindstorm Education Core Set building instructions and it is attached here as a pdf file in the building_instructions folder. They will need to build the robot and if they want they may replace the color sensor with a touch sensor.

  • They can also build another model of robot for g using the attached measuring_g_building_instructions ldd/html file. It’s another flexible model for calculating g with larger balls and using touch sensors.

Next Steps:

  • They load the EV3 brick with a ready-made EV3-dev SD card, which the teacher will give to them.

  • They will set up the network connection between the EV3 and the brick, as described here.

  • They will set up a graphical SSH connection between the EV3 and the PC, as described here.

  • They will establish a WiFi connection between the EV3 and thePC.

(Instructions can be found here).

Effects

When they have completed this lesson they will be able to…

  • Describe the role of gravity in various phenomena, such as free falling objects and keeping a planet in orbit around sun

  • Use the Lego color or touch sensor, the EV3 brick and Python language to measure the time of flight for the falling object

  • Calculate the average velocity of the falling object and Identify the value of g experimentally

  • Construct a plot of velocity versus time for different fall heights, apply a best fit line to the velocity/time graph and obtain the slope of this line, all these actions programmed in a python program.

  • Compare experimental value for g to the standard value of g

  • Propose explanations for any difference between the calculated and standard g.

  • Learn more advanced programming in Python.

At the end of the course after answering self-assessment questions, they can return here to assess how much they have achieved learning goals

Exercise

  • Implement a distributed python program (PC/EV3)

  1. Sensor and motor control is performed on EV3

  2. The computation and graph section for g runs on the PC.

  • What does the Python program do?

  1. It commands the motor to release the object from the claw

  2. Once it hits on the touch / color sensor it counts the down time

  3. Calculates the speed in relation to time for different release heights

  4. Designs a speed / time graph on the computer screen

  5. Calculates and displays the gradient of this graph (it’s the half of experimental value of g)

  • Compare experimental value of g to the standard value of g (9.81 m/sec2).

  1. Compare the values for the measured acceleration of the different objects and different heights tested.

  2. What are the possible explanations for the difference in the values for your measured g and the accepted value of g?

Example solution

Step 1 Import the necessary modules and configure the light sensor for tracking and the servo motor for open/close the claw/object-holder.*

Computer science

Learn how to make a distributed program (with lego and computer segments) and mount the light sensor for tracking and the servo motor for opening/closing the object holder.

Program

#!/usr/bin/env python3

# Import of necessary libraries

import rpyc

conn = rpyc.classic.connect('ev3dev') # host name or IP address of the
EV3

ev3 = conn.modules['ev3dev.ev3'] # import ev3dev.ev3 remotely

from time import time,sleep

from pylab import show, plot, axis, polyfit

#Connect one large motors to any output port

motor = ev3.LargeMotor()

#Plug a light sensor into any sensor port

color = ev3.ColorSensor()

#Test light sensor. if the connection is false trigger an error.

assert color.connected, "Connect a single light sensor"

#Set mode of color sensor

color.mode='COL-REFLECT'

Step 2

Complete the program to ask the user to enter the height of the ball in meters, then open the claw and measure time of free fall. Program should try this repeatedly for different heights and print the list of tested heights and resulting times.

Physics

Forces, Gravity, Free falling bodies

Computer science

Learn how to define and print lists, define variables, make loops, measure elapsed time through color sensor and control servo motor to open and close the object holder.

Program

#!/usr/bin/env python3

# define variables

t0 = 0 # starting time

t1 = 0 # ending time

t_list = []

d_list = []

# Ask the user to enter the height of the ball in meters

d = input("Enter the height of the ball in meters, or 'q' to quit: ")

# Loop until the user enters 'q' to quit

while(d != "q"):

  ev3.Sound.speak("Drop!")

  # open claw

  motor.run_to_rel_pos(position_sp=-50, speed_sp=900, stop_action="hold")

  t0 = time() + 0.07

while(color.value() == 0 or color.value() == 1):

  pass

  t1 = time() - t0

print(t1)

motor.run_to_rel_pos(position_sp=50, speed_sp=700, stop_action="hold")

answer = input("Everything ok with this trial? (y/n) ")

if (answer == 'y') :

  t_list.append(t1)

  d_list.append(eval(d))

  d = input("Enter the height in meters, or 'q' to quit: ")

  print('distance list: ', d_list)

  print('time list: ', t_list)

Step 3 Complete the program in order to print the average velocity list for the different trials, to draw the velocity/time graph best fit line and calculate the graph’s slope which is the experimental g to be printed at the computer screen.

Physics

velocity = distance / time, Gravitational acceleration g

Mathematics

velocity/time graph, best fit line (linear regression), error of linear regression, slope

Computer science

Learn how to make and draw a velocity/time best fit line graph and get its slope which is the experimental g.

Program

#!/usr/bin/env python3

v_list = []

if len(d_list)>=1:

  for i in range(len(d_list)):

    v_list.append(d_list[i]/t_list[i])

    print('velocity list: ', v_list)

if len(d_list)>1 :

  m,b = polyfit(t_list, v_list, 1)

  print("m = ", m, "b = ", b)

  print ('----> Calculated g: ', 2*m, ' <-----')

line_list = []

for i in t_list:

  line_list.append(m*i+b)

  plot(t_list,v_list,'ro', t_list, line_list, '--k')

  axis([0,1,0,4])

  show()

elif len(d_list)==1:

  print ('----> Calculated g: ', 2*v_list[0]/t_list[0], ' <-----')

Summary

In this lesson, we have just learned to program a servo motor for opening the object holder and also to program a light sensor for tracking the fallen object. We are able to open the claw driven from the servomotor, read the value from the light sensor and use it to compute the time of the object’s free fall. This is done repeatedly for different heights. We learnt how to calculate the time and velocity of the object’s fall, draw the best fit line graph of velocity/time and determine this graph’s slope which is the experimental g.

In conclusion, we have presented a lesson allowing the students to practice the physics concept of gravitational acceleration g by calculating it this by means of Robotics, Python programming and application of math concept of line slope.

Next Section - Lego EV3 Robotics, Math and Music