ECE 5725 Spring 2018 Final Project
Abhimanyu Khandelwal -email@example.com
Weiyou Dai -firstname.lastname@example.org
We created a robotic frame and added servo motors and optical encoders to it. We created control algorithms that would precisely control the velocities of each wheel to enable us to exactly determine the robot’s location and orientation. It moves in incremental steps and holds its position for a duration of 5 seconds.
Additionally, we have implemented the ability to turn the robot once it clears a vertical column in the grid so that it can start working on the next vertical column. This process keeps on happening till it has traversed the entire surface.
There are several cases wherein a robot is required to navigate in an environment where there are no external reference points to aid in determining the location or the orientation of the robot. Hence, we decided to implement such a robot using precise motions using on board sensors that did not receive any information from the environment to navigate through a 4x4 grid.
The robot’s design can be broken down into 4 distinct parts:
The base of the robot was cut out of a sheet of acrylic which effectively was a scaled up version of the base of the ECE 5725 Lab 3 robot. The robot had two castor wheels in front which served to balance the robot and also had two plastic wheel mounts at its rear for mounting the servo motors.
Testing: The tests were conducted on the robotic base after attaching the servo motors and wheels to it. We identified potential places where errors could originate and mitigated them such as adjusting the height of the castor wheels to ensure that the robot was resting with its weight equally divided between the front two castors.
The other problem we encountered with the physical structure during testing was that the wheels were touching the acrylic plate because the plastic wheel mounts were bending under the weight of the acrylic plate. We solved this problem by bolstering the wheel mounts with tape.
We made use of Parallax Continuous Rotation Servo Motors(#900-00008) to drive the robot. From the servo motor datasheet, the spinning speed will increase when the PWM on-time decreases from 1.7ms to 1.5ms for counterclockwise rotation; the spinning speed will increase when the PWM on-time decreases from 1.5ms to 1.3ms for clockwise rotation, as shown in the figures below. We attached these motors to each of the plastic wheel mounts with the help of machined nuts and bolts. Additionally, we connected wheels to the servo motors to help the robot move. Lastly, we also created maps that gave us the relationships between each motor’s PWM on time and velocity so that we could implement the PID controllers. This open loop analysis helped us obtain equations that connected the above mentioned quantities. The maps and equations are shown below.
|Types||Wheel velocity vs PWM on-time Equation|
|Primary wheel counter-clockwise||On-time = 6.27 * v / 1000 + 1.51|
|Primary wheel clockwise||On-time = -6.84 * v / 1000 + 1.5|
|Secondary wheel counter-clockwise||On-time = -7.09 * v / 1000 + 1.49|
|Secondary wheel clockwise||On-time = 7.54 * v / 1000 + 1.5|
Below is a code snippet which shows how we implemented the mapping in the python code. We set PWM on-time as 20ms from datasheet, and give the function an updated velocity. We get the PWM on-time from the equation and expect the velocity to change.
Testing: We powered on the servo motors by connecting the power to an external 6 volt power supply and linking the grounds of the power supply and the R-Pi as suggested in the datasheet. We then generated a PWM in software and sent it to the control signal of the R-Pi to test its functionality. We discovered here that the R-Pi’s non real time behaviour led to the generation of unstable PWMs in terms of the frequency and duty cycle. In order to fix this issue we changed the way in which we were generating the PWM from software to hardware by using the R-Pi’s hardware co-processor. This gave us accurate PWM signals for motor control. Additionally, we also had to calibrate the servo motors prior to implementing the PID control so that we could obtain deterministic results in terms of the PWM On Time and the motor velocity. We did this by making a python script(pwm_test.py in Code Appendix section) that sent the desired calibration signal to the control signal of each motor and physically adjusting the screw inside the servo motor.
To implement the encoder pattern detection, initially we used the holes on the wheels. Since the holes on the wheels can provide an accurate distance gap, it is easy for the optical encoder to generate a steady and consistent speed measurement. We attached white tapes on the holes on the wheels so that they can appear white while the framework of the wheel stay black as the encoder disk pattern. Then we glued the optical encoders right above the servo motors, pointing outward to the encoder disk side on the wheels. It worked as expected and can give us a reliable measurement but did not give us the desired resolution. For example, given the encoder disk pattern, it could only provide us a resolution of 3 holes per second. It was good but not enough for our PID controllers to respond. Therefore, after researching and consulting, we decided to switch to a general encoder disk which has black and white straps in between as shown on the figure below. The new encoder disk give us more resolution in term of measurement and the resolution increased up to 10 turns per second.
We also encountered a problem with the wheels of the robot wherein the wheels of the robot would slip. This was happening because the weight of the robot was too large and there were countless dust on the floor. In order to solve this issue, we first tried wrapping the wheels with wide rubber bands. However, the rubber bands would become loose and deteriorate, preventing us from using them as a robust solution. Ultimately, we moved onto using abrasive anti-slip tape on both wheels. The tape offered enough traction to prevent the wheels from skidding while going straight.
Lastly, we powered the servo motors using an external battery pack. We did this because we wanted an uninterrupted power supply for the R-Pi. When the motors start moving, they draw a significant amount of current which reduces the voltage of the battery. If this battery were also connected to the R-Pi, the drop in voltage could be large enough to momentarily turn the R-Pi off.
In order for us to keep track of the robot’s orientation and position without making use of external references such as distance from walls, we made use of Pololu optical encoders. These were essentially distance sensors which measured if they saw an obstruction in their region of operation. These sensors gave us the velocity of each wheel.
Testing: We mounted the optical encoder directly onto the servo motors and initially made use of the holes in the wheels to measure obstruction. We covered the outer side of the wheel using white tape so that it formed a “wall” which would block the signal from the optical encoder. It gave us a reading every time there was a transition in the reflecting surface i.e. whenever the optical encoder saw that the reflection surface changed from the wheel to the white tape that was attached in the background. This gave us slightly unstable readings which is why we added debounce time in our program so that we could capture when the wheel was actually turning. However, as we progressed with the PID controllers, we realized that the resolution we were getting from the taped wheel was not enough which is why we opted to go for an encoder disk. Upon doing so, we ran into another problem because the optical encoder was unable to detect any transitions. To solve this issue, we kept altering the distance and the angle of the optical encoder from the encoder disk till we obtained a clean and stable signal. We repeated this process for the other optical encoder as well to get both of them to function properly.
To make sure that we could control the robot’s orientation and location, we made use of PID controllers. We needed to make the robot travel at a fixed speed throughout and also needed to make both the wheels of the robot turn at the same speed so that the robot travelled in a straight line. 
The first PID control that we implemented was for the left wheel (denoted as the primary wheel from here on), to control its velocity. The velocity of the primary wheel was being maintained by first reading the velocity of the wheel and checking if it was spinning at the desired speed. If there was a variation in the measured speed and the desired speed, the difference in speed was used in the PID equation to generate the new velocity. This new velocity was then transformed to the PWM on-time using our velocity to PWM on-time mapping we generated earlier, thereby controlling the speed of the motor. The P term, by itself, proved to generate accurate control.
Testing: We first tested this module by applying random external forces to the wheel and measuring the velocity trend afterwards. We tuned the P term till we were able to reduce the overshoot in velocity and settling time to the reference velocity.
We implemented the second PID controller so that the secondary wheel (right wheel) followed the primary wheel. It kept track of the measured velocity of the primary wheel and the measured velocity of the secondary wheel and if there was a variation in the two values, it made use of the PID equation to generate a adjustment velocity. This was transformed into the PWM on time for the secondary motor and its velocity was adjusted.
Testing: We tested the this by randomly applying forces to the primary wheel and observing the velocity response of the secondary wheel. We tuned the P term, which was the only term required, till we achieved acceptable overshoot and settling time for the motor velocity.
We managed to design, build and test the robot to move as instructed. However, the robot needed to be manually adjusted every time it turned but apart from that, it was able to traverse the rectangular area fairly well. Hence, the robot performed closely in accordance with our initial objective.
This robot was a fairly complex build since it required to be able to traverse a fixed rectangular area without using an external reference points in the environment. It’s functionality had high fidelity while going straight but needed slight manual adjustment during turning. This project serves as a versatile base for a plethora of applications such as cleaning robots.
PID algorithm design, hardware assembly,implementation, report
PID algorithm design,implementation, debug, report
We encountered a few issues which led to the non-ideal performance of the robot. Hence, if we had more time, we could have worked on solving the following issues:
The primary issue we faced was due to the floor’s imperfections. If the floor was perfectly flat and identical in the testing area, it is possible that our results would have been significantly better. Hence, it is possible and likely that running the robot on a perfectly flat surface would make the below mentioned issues irrelevant.
The wheels did skid while the robot was making a turn which made the robot loose its fine tuned location tracking. We could reduce the speed of the motors which would have mitigated this issue.
Whenever the wheels moved, the current drawn by the motor led to a decrease in the battery voltage. There is a chance that this could have affected the map we had created to relate the velocity and the PWM on time. We would have liked to run more tests using a stable external supply to see if this was truly affecting the wheel velocity significantly.
The castors were non-identical and could have contributed to the imperfect motion of the robot. We could have tried to make use of more identical castors.
We had worked on the ultrasonic distance sensor  and had got it to determine the distance to the obstacle. However, we did not implement it in the final design due to time constraints.
Anon, (2018). [ebook] Available at: https://www.parallax.com/sites/default/files/downloads/900-00008-Continuous-Rotation-Servo-Documentation-v2.2.pdf [Accessed 18 May 2018].
Lowes. (2018). [online] Available at: https://www.lowes.com/pd/SKID-GUARD-Reflective-Mineral-Abrasive-Anti-Slip-Tape/3185621 [Accessed 18 May 2018].
"Pololu Carrier with Sharp GP2Y0D810Z0F Digital Distance Sensor 10cm", Pololu.com, 2018. [Online]. Available: https://www.pololu.com/product/1134. [Accessed: 18- May- 2018].
U. HC-SR04, "Ultrasonic Sensor - HC-SR04 - SEN-13959 - SparkFun Electronics", Sparkfun.com, 2018. [Online]. Available: https://www.sparkfun.com/products/13959. [Accessed: 18- May- 2018].
"How to Build a Robot Tutorials - Society of Robots", Societyofrobots.com, 2018. [Online]. Available: http://www.societyofrobots.com/sensors_encoder.shtml. [Accessed: 18- May- 2018].