Controller Design Process
Assumptions
Initially, the given assumptions were that a DC voltage would be input to the controller, which would correspond to the amount of power in the signal being received by the receiver. The circuit to perform this task was designed and tested to validate that assumption.
The second assumption was that the voltage was a function of the orientation of the antenna, with an optimal maximum voltage level when the receiver was directly oriented with the transmitter, as seen below in Figure 1.
With the designed circuits, we were able to test that this second assumption was validated. When the transmitter was oriented directly with the receiver, the voltage was at a maximum around 2V - 2.5V. When the transmitter was moved to the left or to the right of this angle, the voltage would decrease and saturate to a low value of about 1.5V. This 0.5V - 1V range is wide enough for the controller algorithm to use to find the peak of the voltage to angle function.
While these assumptions were being validated, a control simulation was developed in MATLAB and Simulink in order to demonstrate that the theory would be applicable for the problem at hand.
Initially, the given assumptions were that a DC voltage would be input to the controller, which would correspond to the amount of power in the signal being received by the receiver. The circuit to perform this task was designed and tested to validate that assumption.
The second assumption was that the voltage was a function of the orientation of the antenna, with an optimal maximum voltage level when the receiver was directly oriented with the transmitter, as seen below in Figure 1.
With the designed circuits, we were able to test that this second assumption was validated. When the transmitter was oriented directly with the receiver, the voltage was at a maximum around 2V - 2.5V. When the transmitter was moved to the left or to the right of this angle, the voltage would decrease and saturate to a low value of about 1.5V. This 0.5V - 1V range is wide enough for the controller algorithm to use to find the peak of the voltage to angle function.
While these assumptions were being validated, a control simulation was developed in MATLAB and Simulink in order to demonstrate that the theory would be applicable for the problem at hand.
Feedback Controller
The block diagram of the feedback control is shown in Figure 2. This design was chosen due to the simplicity of implementing it relative to PD, PI, or PID control while having the ability to successfully bring the error of the system to zero. A PID control scheme was also designed and tested as will be shown later.
This proportional feedback control in Figure 2 implements a basic proportional gain. However, since a reference voltage is not known, it uses the past input voltage to calculate the error. Therefore if the receiver is rotating in the correct direction, the error will be positive, while if the receiver is rotating in the wrong direction, it will be negative. The controller is implemented as follows:
speed = K*e
This is the basic controller that was first implemented in C on the Arduino. The value of the gain had to be experimentally determined through trial-and-error. An optimal value found during testing was K = 4.4. It was found during tests that the inertia of the load made it difficult for the DC motor to begin rotating below speeds of 15 rpm. Thus, a constant had to be added to the equation so that the system would overcome the inertia when it expected to rotate. The new control law became:
speed = K*e + 15
The 15 in the equation and the 15 rpm are not related. The 15 in the equation was experimentally determined to optimally control the antenna.
A PID controller was also implemented and tested based on the derivations found here. The implemented control law is:
speed = speed + k*(e[0] - e[1]) + ki*e[0] + kd*(e[0] - 2*e[1] + e[2])
where k is the proportional gain, ki is the integral gain, and kd is the derivative gain. e[0] is the error between the current sample and the past sample. After every iteration, this value is pushed through the e array to e[1], then to e[2], to compute the proportional and derivative components of the equation. Again, the value of k, ki, and kd have to be experimentally determined. After a lot of testing and experimentation, the performance of the system was not improved with the PID controller in comparison to the P controller and it was judged that it was not worth further time and effort to develop the PID controller when the P controller performed well.
Logic and Thresholds
The system performs two functions based on input switches to the microcontroller. These are to run the controller developed above and to perform a 360 degree scan. The scan is a simple function that rotates the receiver around 360 degrees and reads in voltage values as it rotates. The maximum voltage is remembered during the sweep. After the sweep, the receiver is rotated backwards until the voltage being measured is 180mV within the maximum. This brings the antenna close to the optimal position and the control software can then be ran afterwards. The motion of the receiver is thresholded so that the system doesn't rotate when the error in voltage is fairly low. Based on the equation of the proportional controller, even a small error should generate some speed. The threshold implemented is that the error in consequent voltage measurements must be above 60mV for the system to rotate. This was based on experimentation and observation of the voltage when the transmitter is not moving. Finally, the speed of the system was thresholded so that high speeds are not sent to the motor, which could potentially damage the hardware.
Another feature of the software is to detect when the antenna has lost signal for a period of time and correct itself. The issue is that when the antenna is in the completely wrong direction, there is very little correlation between the correct direction of motion and changes in voltage. Therefore, since the optimal voltage is remembered, the software checks every voltage sample with this maximum. If the input is below 70% of the maximum 15 times in a row, the system performs a scan function again, which brings it back to near the optimal angle.
Microcontroller
To implement the controller, an Arduino Microcontroller was used with a Motor Shield to interface to the DC motor, which rotates the receiving antenna. C code was developed in the Arduino integrated development environment software to interface with digital and analog input pins. The software has two functions controlled by switches to the digital input pins. The first function is to perform a scan, which rotates the antenna in a full circle while reading the input voltage, then going back to the position that had the maximum voltage; this gets the antenna close to the optimal position. The second function enables the PID feedback controller, which maintains the antenna at the optimal position even when the transmitter is rotated around the receiver. The voltage is read in through analog input pins of the Arduino board. Research had to be done in order to determine how to interface the software with the motors being used. Both stepper motors and DC motors were used in the testing of the prototype, but it was found that the DC motor had the best ability to provide the necessary torque to rotate the reflector and receiver. Figure 3 shows the flowchart of the controller software.
The block diagram of the feedback control is shown in Figure 2. This design was chosen due to the simplicity of implementing it relative to PD, PI, or PID control while having the ability to successfully bring the error of the system to zero. A PID control scheme was also designed and tested as will be shown later.
This proportional feedback control in Figure 2 implements a basic proportional gain. However, since a reference voltage is not known, it uses the past input voltage to calculate the error. Therefore if the receiver is rotating in the correct direction, the error will be positive, while if the receiver is rotating in the wrong direction, it will be negative. The controller is implemented as follows:
speed = K*e
This is the basic controller that was first implemented in C on the Arduino. The value of the gain had to be experimentally determined through trial-and-error. An optimal value found during testing was K = 4.4. It was found during tests that the inertia of the load made it difficult for the DC motor to begin rotating below speeds of 15 rpm. Thus, a constant had to be added to the equation so that the system would overcome the inertia when it expected to rotate. The new control law became:
speed = K*e + 15
The 15 in the equation and the 15 rpm are not related. The 15 in the equation was experimentally determined to optimally control the antenna.
A PID controller was also implemented and tested based on the derivations found here. The implemented control law is:
speed = speed + k*(e[0] - e[1]) + ki*e[0] + kd*(e[0] - 2*e[1] + e[2])
where k is the proportional gain, ki is the integral gain, and kd is the derivative gain. e[0] is the error between the current sample and the past sample. After every iteration, this value is pushed through the e array to e[1], then to e[2], to compute the proportional and derivative components of the equation. Again, the value of k, ki, and kd have to be experimentally determined. After a lot of testing and experimentation, the performance of the system was not improved with the PID controller in comparison to the P controller and it was judged that it was not worth further time and effort to develop the PID controller when the P controller performed well.
Logic and Thresholds
The system performs two functions based on input switches to the microcontroller. These are to run the controller developed above and to perform a 360 degree scan. The scan is a simple function that rotates the receiver around 360 degrees and reads in voltage values as it rotates. The maximum voltage is remembered during the sweep. After the sweep, the receiver is rotated backwards until the voltage being measured is 180mV within the maximum. This brings the antenna close to the optimal position and the control software can then be ran afterwards. The motion of the receiver is thresholded so that the system doesn't rotate when the error in voltage is fairly low. Based on the equation of the proportional controller, even a small error should generate some speed. The threshold implemented is that the error in consequent voltage measurements must be above 60mV for the system to rotate. This was based on experimentation and observation of the voltage when the transmitter is not moving. Finally, the speed of the system was thresholded so that high speeds are not sent to the motor, which could potentially damage the hardware.
Another feature of the software is to detect when the antenna has lost signal for a period of time and correct itself. The issue is that when the antenna is in the completely wrong direction, there is very little correlation between the correct direction of motion and changes in voltage. Therefore, since the optimal voltage is remembered, the software checks every voltage sample with this maximum. If the input is below 70% of the maximum 15 times in a row, the system performs a scan function again, which brings it back to near the optimal angle.
Microcontroller
To implement the controller, an Arduino Microcontroller was used with a Motor Shield to interface to the DC motor, which rotates the receiving antenna. C code was developed in the Arduino integrated development environment software to interface with digital and analog input pins. The software has two functions controlled by switches to the digital input pins. The first function is to perform a scan, which rotates the antenna in a full circle while reading the input voltage, then going back to the position that had the maximum voltage; this gets the antenna close to the optimal position. The second function enables the PID feedback controller, which maintains the antenna at the optimal position even when the transmitter is rotated around the receiver. The voltage is read in through analog input pins of the Arduino board. Research had to be done in order to determine how to interface the software with the motors being used. Both stepper motors and DC motors were used in the testing of the prototype, but it was found that the DC motor had the best ability to provide the necessary torque to rotate the reflector and receiver. Figure 3 shows the flowchart of the controller software.