The PID Controller – Part 4 of 4

← Back to Part 1 – Introduction and some math
← Back to Part 2 – Some more math 🙂
← Back to Part 3 – The  PIDController class
↓   Download the source code (Please register before proceeding to download)

As an example of the application of the  PIDController class, here I present you the  MediumMotorPositionPID class whose main feature is the angular position regulation of the Ev3 Medium Motor. From the Lego shop website:

The Lego Mindstorms Ev3 Medium Motor
The Lego Mindstorms Ev3 Medium Motor

The EV3 Medium Servo Motor is great for lower-load, higher speed applications and when faster response times and a smaller profile are needed in the robot’s design. The motor uses tacho feedback for precise control within one degree of accuracy and has a built-in rotation sensor.

  • Tacho feedback to one degree of accuracy
  • 240-250 RPM
  • Running torque of 8 (approximately 11
  • Stall torque of 12 (approximately 17
  • Auto-ID is built into the EV3 software

The MediumMotorPositionPID class is derived from the  PIDController ; it has a  Motor property that you can use to assign the output port of the Ev3 Brick to which you have connected the medium motor; also, there are the  Start() and the  Stop() methods that you use to control the PID thread. When the thread is stopped, the motor is stopped too and brake is turned on. The  OutputSignal protected setter is overridden to assign the output of the PID controller to the motor raw (force) output.

You can compile the code I propose in this page using Xamarin Studio 5.10.1 (Build 6), with Mono 4.2.1 as active runtime and the Monobrick Firmware Library to let it work on board the Lego Mindstorms Ev3 with the Monobrick firmware.

An application of this class is the Sup3r Car, where a PID controller has been used on the steering motor.

The source code happily shared above is subject to the Code Project Open Licence (CPOL) 1.02, hoping that you will enjoy it!

The PID Controller – Part 4 of 4
Tagged on: