Team 3 - Electronics and Software

Components Used:

12V DC Power Supply

Arduino Uno Rev3

Arduino Motor Shield Rev3

12V DC Gearmotor with Encoder

   

Feedback Loop:

The system uses an encoder that outputs 240 pulses per revolution to measure the motor speed. While implementing the velocity profile for the mechanism, the encoder is also used to keep track of how much the input gear has rotated.

The speed of the motor is calculated using the following function.

where,

encoder0Pos is the encoder reading during the current loop, 

encoderLastPos is the encoder reading during the previous loop.

delayTime is the delay between each loop and is equal to 20 ms

PulsesPerRev is the number of encoder pulses per revolution and is equal to 240


The number of rotations of the input gear is measured using the following function.

After 9 rotations of the input gear, the output gear returns to its starting position and therefore the number of rotations is reset to 0 in the code.

PID Implementation:

A PID controller was implemented using the PID_v1_bc library. This library is the updated version of the original PID library for Arduino and solves certain issues including Integral windup and derivative kick.

The documentation for the library can be found here.

The PID gains were tuned using the Ziegler-Nichols method and then manually adjusted until the required behavior was obtained.

PID Performance:

The following section analyzes the performance of the PID controller.

At high speeds (>230 rpm), the controller tracks the reference value well as seen in the images below. The first image shows the speed of the motor without using the PID controller and the second image shows the speed of the motor with the controller.

As seen above, without the PID controller the motor is unable to reach the reference speed. The spike in the PID response plot is due to issues with the circuit which cause the motor to stutter every time it was turned on. This issue was solved by adding a switch and leaving it open when the motor was first turned on.


At low speeds (<120 rpm), the pid improves the behavior of the motor, however, oscillatory behavior is noted and was difficult to alleviate no matter the PID gains. The first image below shows the response of the motor at 60 rpm without PID control and the second image shows the response at 60 rpm with PID control. Once again, the initial spike is due to the stuttering of the motor upon supplying it with power and was once again solved by adding a switch. 

We theorize that the oscillatory behavior noted at low speeds is due to stiction which needs to be overcome before the motor shaft can begin to spin.