Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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.

Image Added

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.

Image Added

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.

...