Difference: ExerciseSheets (13 vs. 14)

Revision 142022-11-14 - UliRaich

Line: 1 to 1
 
META TOPICPARENT name="ASP2022"

Exercises

Line: 9 to 9
 Connect your ESP32 to the PC using the micro USB cable and start thonny. Locate the shell window and check if you see the REPL prompt ">>>". If not, try to press <enter>. Make sure the shell window has the input focus. If this does not work, press the stop button. If this also doesn't help, press the reset button on the ESP32 CPU board.

Playing with REPL

  • print "Hello World!"
Changed:
<
<
  • calculate 127,9 * 157.6 * 17.2 /(3.5*2**4) 2**4 means 2 to the power of 4
    you may try to calculate e.g 2**4 separately first and check that you get the result expected
>
>
  • calculate 127,9 * 157.6 * 17.2 /(3.5*2**4), 2**4 means 2 to the power of 4
    you may try to calculate e.g 2**4 separately first and check that you get the result expected
 
  • continue experimenting with REPL

Hello World

Line: 79 to 76
  If the above is too simple for you, you may try to calculate the throwing parabola. Let's say, a stone is thrown at a speed of 30m/s and an angle of 30° with respect to ground. Calculate the trajectory of the stone until it hits the ground. You may define a function trajectory, taking as parameters the initial speed, the angle and the time resolution for which you want to calculate the stone positions.
Changed:
<
<
v_hor = v_initial * cos(angle)
>
>
v_hor = v_initial * cos(angle)
 v_ver = v_initial * sin(angle)
Deleted:
<
<
 x(t) = v_hor * t
Changed:
<
<
y(t) = v_ver * t - 1/2 * g * t**2
>
>
y(t) = v_ver * t - 1/2 * g * t**2
  Like this, you can easily calculate the trajectories for different angles and different initial speeds.
Line: 96 to 90
 tp_45 is the trajectory for 45 degrees.

Plotting is done as described above. When plotting several data files, use

Deleted:
<
<
 
replot "data_file.dat" with lines

in order to avoid deleting the previous plot.

Added:
>
>

Improving the program

This program can further be improved by plotting the same number of points for each parabola. To achieve this, we can first calculate the total flight duration until the object hits the ground again:

vt = 1/2*g*t**2, v => 1/2*g*t, t= 2*v/g

Then we calculate a fixed number of points (e.g. 50) for each parabola in a for loop.

Like this, we can easily see that for an angle of 30° and 60° the distance covered is the same. This is also true for 10° and 80° or 20° and 70°.

trajectories_V2.png

 

End of the second exercise session

Line: 182 to 184
 
META FILEATTACHMENT attachment="helloWorld.png" attr="" comment="" date="1665842121" name="helloWorld.png" path="helloWorld.png" size="73165" user="UliRaich" version="1"
META FILEATTACHMENT attachment="gnuplot_sin.png" attr="" comment="" date="1665866878" name="gnuplot_sin.png" path="gnuplot_sin.png" size="30601" user="UliRaich" version="1"
Changed:
<
<
META FILEATTACHMENT attachment="exercises.odt" attr="" comment="" date="1666623199" name="exercises.odt" path="exercises.odt" size="210099" user="UliRaich" version="2"
>
>
META FILEATTACHMENT attachment="exercises.odt" attr="" comment="" date="1668441417" name="exercises.odt" path="exercises.odt" size="571588" user="UliRaich" version="3"
 
META FILEATTACHMENT attachment="trajectories.png" attr="" comment="" date="1666445815" name="trajectories.png" path="trajectories.png" size="58903" user="UliRaich" version="1"
META FILEATTACHMENT attachment="led_color_wheel.png" attr="" comment="" date="1666630102" name="led_color_wheel.png" path="led_color_wheel.png" size="169186" user="UliRaich" version="1"
Added:
>
>
META FILEATTACHMENT attachment="trajectories_V2.png" attr="" comment="" date="1668439751" name="trajectories_V2.png" path="trajectories_V2.png" size="69040" user="UliRaich" version="2"
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback