PoE: Lab 3 -- PID Control
Objectives
- Use an analog IR reflective sensor to measure the angular position of a motor shaft.
- Create a closed-loop controller for a brushed DC motor with your DIY shaft encoder.
- Characterize and visualize the performance of your closed-loop motor controller.
After setting up the sensor circuit with the Arduino, we began to build the encoder. An encoder is a circle with distinct patterns of black and white shapes, usually triangles, that signify on-off or high-low. We placed our 36-resolution*, carboard encoder right on the shaft of the motor for it to spin in relation to the motor's position. (*Note: Determine by dividing circumference by sensor's width)
Rather than soldering longer wires onto the sensor for it to be mounted, we mounted the breadboard on which it lay and placed that directly across from the encoder for it to read. We had a few challenges in calibrating the sensor as we couldn't understand the schematic at first and forgot about the internal LED in relation to the 4 pins of the sensor. Once we started receiving readings from the sensor, we tried to find consistent values for High/Low or Black-White patterns. We build the motor's mount out of foam, leaving room for the encoder to spin and, on the other end, for the load (paperclip and hex nut) to oscillate during the 120-degree run.
We can assign a target distance to the code, depending on how many degrees we want the encoder to rotate. For our 90 degree step function, our target value was 18. The code also keeps track of our error, which is the target position minus the position count. The position is supposed to continue updating until it reaches the target, but without a PID control, our error never reaches zero. Hence, PID control, first multiplying the error value by the proportional constant and converting this number into a speed input for the motor. We experimented with the value of the proportional constant (Kp), until it simply oscillated around the target position. We then experimented with derivative control to apply a break to proportional control, slowing the motor down as the output shaft position approaches the target position: multiplying the error difference by the derivative constant (Kd). However, with just P and D control, the position stays just below the target, so we implemented an integral control, which takes the integral of all error values and multiplies this by Ki, the integral constant. With the PID control in place, the motor just overshoots the target position slightly but then returns and stays steady at the target position.
Comments
Post a Comment