expand q2, fix formatting
This commit is contained in:
@@ -11,8 +11,6 @@ geometry:
|
|||||||
\maketitle
|
\maketitle
|
||||||
\thispagestyle{empty}
|
\thispagestyle{empty}
|
||||||
\newpage
|
\newpage
|
||||||
\tableofcontents
|
|
||||||
\newpage
|
|
||||||
|
|
||||||
# Question 1
|
# Question 1
|
||||||
|
|
||||||
@@ -27,8 +25,11 @@ maybe not push enough current to motor to actually get it spinning in some cases
|
|||||||
# Question 2
|
# Question 2
|
||||||
|
|
||||||
When derivative control is added at low levels (0.02) it reduces the oscillations.
|
When derivative control is added at low levels (0.02) it reduces the oscillations.
|
||||||
|
|
||||||
This is because derivative control only considers the rate of change of of the error
|
This is because derivative control only considers the rate of change of of the error
|
||||||
and therefore tries to bring the rate of change to zero.
|
and tries to bring the rate of change to zero.
|
||||||
|
This means that adds a *damping* effect to the controller, slowing it down when it's moving,
|
||||||
|
and thereby reducing/eliminating overshoot and oscillations.
|
||||||
|
|
||||||
# Question 3
|
# Question 3
|
||||||
|
|
||||||
@@ -68,18 +69,23 @@ Some initialisation is run in `setup` on lines 89 and 90:
|
|||||||
Then the main control loop starts.
|
Then the main control loop starts.
|
||||||
The `loop` function runs the `controlLoop` function every 20 milliseconds (as defined by
|
The `loop` function runs the `controlLoop` function every 20 milliseconds (as defined by
|
||||||
`controlInterval`) on line 101.
|
`controlInterval`) on line 101.
|
||||||
|
|
||||||
The `controlLoop` function retrieves the current motor position and stores it in the variable
|
The `controlLoop` function retrieves the current motor position and stores it in the variable
|
||||||
that the PID controller has a pointer to.
|
that the PID controller has a pointer to.
|
||||||
|
|
||||||
`myPID.Compute()` is then called to recompute the motor speed required to get to the set point
|
`myPID.Compute()` is then called to recompute the motor speed required to get to the set point
|
||||||
and this is stored in the `percentSpeed` variable as the controller has a pointer to it.
|
and this is stored in the `percentSpeed` variable as the controller has a pointer to it.
|
||||||
This new speed is passed to the `driveMotorPercent` function to update the motor's speed.
|
This new speed is passed to the `driveMotorPercent` function to update the motor's speed.
|
||||||
|
|
||||||
|
\newpage
|
||||||
|
|
||||||
# Question 5
|
# Question 5
|
||||||
|
|
||||||
The mathematically complex operations in `loop()` as it is run infrequently.
|
The mathematically complex operations in `loop()` as it is run infrequently.
|
||||||
This is because it is inside an if statement with condition `convertNewNumber()`, which
|
This is because it is inside an if statement with condition `convertNewNumber()`, which
|
||||||
returns `false` if there is no new data to convert (i.e. if there has not been any serial input
|
returns `false` if there is no new data to convert (i.e. if there has not been any serial input
|
||||||
since the last loop).
|
since the last loop).
|
||||||
|
|
||||||
Essentially, the complex operations only run once per serial input, meaning it is run very infrequently
|
Essentially, the complex operations only run once per serial input, meaning it is run very infrequently
|
||||||
compared to how many times the loop runs.
|
compared to how many times the loop runs.
|
||||||
|
|
||||||
@@ -104,9 +110,11 @@ of the shaft, as the magnets of the motor will not be aligned as needed.
|
|||||||
This is also why the steppers use a ramp function, so that the shaft has time accelerate to the
|
This is also why the steppers use a ramp function, so that the shaft has time accelerate to the
|
||||||
desired speed without skipping steps.
|
desired speed without skipping steps.
|
||||||
|
|
||||||
|
\newpage
|
||||||
|
|
||||||
# Question 8
|
# Question 8
|
||||||
|
|
||||||
```{ .matplotlib caption="A plot of velocity and acceleration for SimplisticRampStepper" dpi=150 }
|
```{ .matplotlib caption="A plot of velocity and acceleration for SimplisticRampStepper" dpi=300 }
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
@@ -122,17 +130,20 @@ data = np.genfromtxt("csv/SimplisticRampStepper_out_50.csv",
|
|||||||
fig, ax1 = plt.subplots()
|
fig, ax1 = plt.subplots()
|
||||||
ax2 = ax1.twinx()
|
ax2 = ax1.twinx()
|
||||||
|
|
||||||
ax1.plot(data[TIME], data[SPEED], label='Speed [steps/s]', color='tab:blue')
|
lines1 = ax1.plot(data[TIME], data[SPEED], label='Speed [steps/s]', color='tab:blue')
|
||||||
ax2.plot(data[TIME], data[ACCEL], label='Acceleration [steps/s^2]', color='tab:red')
|
lines2 = ax2.plot(data[TIME], data[ACCEL], label='Acceleration [steps/s^2]', color='tab:red')
|
||||||
ax1.set_ylabel('Speed [steps/s]')
|
ax1.set_ylabel('Speed [steps/s]')
|
||||||
ax2.set_ylabel('Acceleration [steps/s^2]')
|
ax2.set_ylabel('Acceleration [steps/s^2]')
|
||||||
|
|
||||||
|
lines = lines1 + lines2
|
||||||
|
ax1.legend(lines, [ l.get_label() for l in lines ])
|
||||||
|
|
||||||
ax1.set_xlabel("Time [s]")
|
ax1.set_xlabel("Time [s]")
|
||||||
|
|
||||||
fig.tight_layout()
|
fig.tight_layout()
|
||||||
```
|
```
|
||||||
|
|
||||||
```{ .matplotlib caption="A plot of velocity and acceleration for LeibRampStepper" dpi=150 }
|
```{ .matplotlib caption="A plot of velocity and acceleration for LeibRampStepper" dpi=300 }
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
@@ -148,11 +159,14 @@ data = np.genfromtxt("csv/LeibRampStepper_out_50.csv",
|
|||||||
fig, ax1 = plt.subplots()
|
fig, ax1 = plt.subplots()
|
||||||
ax2 = ax1.twinx()
|
ax2 = ax1.twinx()
|
||||||
|
|
||||||
ax1.plot(data[TIME], data[SPEED], label='Speed [steps/s]', color='tab:blue')
|
lines1 = ax1.plot(data[TIME], data[SPEED], label='Speed [steps/s]', color='tab:blue')
|
||||||
ax2.plot(data[TIME], data[ACCEL], label='Acceleration [steps/s^2]', color='tab:red')
|
lines2 = ax2.plot(data[TIME], data[ACCEL], label='Acceleration [steps/s^2]', color='tab:red')
|
||||||
ax1.set_ylabel('Speed [steps/s]')
|
ax1.set_ylabel('Speed [steps/s]')
|
||||||
ax2.set_ylabel('Acceleration [steps/s^2]')
|
ax2.set_ylabel('Acceleration [steps/s^2]')
|
||||||
|
|
||||||
|
lines = lines1 + lines2
|
||||||
|
ax1.legend(lines, [ l.get_label() for l in lines ], loc='upper right')
|
||||||
|
|
||||||
ax1.set_xlabel("Time [s]")
|
ax1.set_xlabel("Time [s]")
|
||||||
|
|
||||||
fig.tight_layout()
|
fig.tight_layout()
|
||||||
|
|||||||
Reference in New Issue
Block a user