Skills Mapping
Dr T. Assaf - 24/11/2023
Schedule:
Tuesday, Week 7, 8 and 9 .

Application of Skills


Introduction

The previous labs focused on building your knowledge to provide a strong foundation for successfully completing the following tasks. Each task will challenge you to apply your knowledge in practical scenarios, allowing you to showcase your abilities.

Please note that the expectation is that each tasks requires one lab session (i.e. two hours).

Task C

In Task C, you will calculate the speed of the motor by acquiring the encoder signals and display the motor speed as RPM, along with the motor states (Halt, Forward, Backward) from TASK B, on the serial monitor. If you have any doubts, please refer to previous activities or ask for assistance.

Another crucial piece of information to calculate the motor speed (RPM) is the gear ratio. To help you calculate this, you can refer to the motor datasheet here or a similar source, depending on the gear ratio of your motor.

Additionally, you will need to use the encoder library. Found at this page. You can install it, if needed, via library manager searching for ESP32Encoder. You can find further details on the moodle FORUM post. The old library who is no longer working on the ESP32 (unless it will be updated in the future) can befound here page. Although it does not work for you, the page is really well structured and can assist you in understanding the other one.

Example to make the library work

#include <InterruptEncoder.h>
InterruptEncoder encoder; // Create the entity (handler)

void setup() {
  encoder.attach(9, 10); // attach the pins
  Serial.Begin(9600);
}
Code snippet
void loop() {
  long test = encoder.read(); //read count
  Serial.println(test);

}
Code snippet

Task D

In Task D, you will combine tasks B and C (or serial monitor or other inputs) to change the motor speed (0% = 0 speed, 100% = maximum speed). You will display the motor speed in RPM, trimmer value, and motor states (backward, halt, forward) on the serial monitor. You can use a switch, button, or the serial monitor to provide direction signals to the motor. You can learn how PWM works by following the example found here.

Task E

No PID libraries are allowed.

In Task E, you will enhance Task D by implementing PID motor control. You will set a target position for the motor using the trimmer values or another input methodology. The motor should then move to the target position and remain there, even in the presence of disturbances. As an example, consider the following target values for the trimmer: 0% = -180°, 50% = 0°, 100% = 180°. When you rotate the trimmer, the motor shaft will rotate, and the motor shaft will settle at the given angle value. You can adjust the overshoot and the steady-state of the signal provided by the trimmer by changing the PID constants. On the serial monitor, you will display the motor speed (RPM), target position, and actual position. You can copy and paste this data to generate better plots in Excel.

If it is not possible to move the data, you can use the plot feature of the Arduino IDE and then label the lines using image editors.