November 10, 2015
Mentor – Dr. M. D. Singh
Other Contributors – Shubham Sharma
The Freescale Cup is a competition where students from universities located all over the world design, build, program and race a model car around the track for speed. We (a team of two) represented our university at the Freescale Cup 2015 held at Indian Institute of Sciences, Bangalore (India). We achieved the best lap time among all the participants from across the country in the preliminary rounds and qualified for the finals. In this post, I describe the design and technical implementation of the robot.
You can view a running video of the robot here.
The robot senses the path and autonomously positions itself to follow it. Parallax TSL1401-DB CMOS linear sensor based camera module was used to detect the black line. The position obtained after processing the data received from this 128 pixel line scan camera was used to generate pulse width modulation (PWM) control signals for the steering servo motor coupled to the front wheels to guide the robot on the specified path. Further, the speeds of dual DC motors driving the rear wheels of the robot were adjusted to prevent slipping. The robot uses the Kinetis KL25Z, ARM architecture based microcontroller from Freescale semiconductors to carry out its data acquisition, processing and control activities.
Detecting the line via the linear sensor was the most crucial part of this project. The first challenge to start with was to interface the sensor module to the microcontroller. SI and CK are the control signals used to do this. The frequency of CK (clock) signal determines the rate at which the analog signals corresponding to the 128 pixels are released one by one on the analog output (AO) line of the sensor. Thus, the time between two consecutive pulses on the CK line should be greater than the sampling time required by the ADC (Analog- Digital convertor) peripheral of the microcontroller. This can be achieved in two ways.
The first way is to give a CK pulse, initialize the AD conversion, wait for conversion to complete, save the conversion data and then give the next CK pulse. Thus, the software has to wait for the AD conversion to complete. The second way is to utilize hardware to give a clock signal having frequency such that the ADC peripheral gets sufficient time to complete the conversion. Further, the ADC is linked to an interrupt which is utilized to save the data as soon as the conversion is completed. Thus, the software is not required to wait for the AD conversion to complete.
The frequency of SI signal is inversely proportional to the time provided to the microscopic array of capacitors to gain charge at a rate proportional to intensity of light incident on them commonly known as the integration time. With a very long integration time, all pixels with saturate even in low lighting conditions. Similarly, with very short integration time, the pixels will not gain much charge even if there is excessive lighting in the environment. Thus, choosing the optimum value of integration time is a very important task. We designed a custom algorithm that could compute this value with respect to any ambient lighting condition.
Once, the microcontroller was able to compute the position of the black line, the next step was to link this position to width of PWM signals which were used to control the steering servo motor. The PWM signal was generated using eMIOS (modular input-output system) peripheral functioning in OPWMB (Output pulse width modulation buffered). The frequency of the PWM signal was set at 50 Hz corresponding to 20 milliseconds which is the minimum time after which the servo used in the project: Futaba S3010 recognizes a new command. The width of the signal was varied according to the sensed position of line by the following linear relations.
It was observed, that 1400 was the PWM value corresponding to central position. Similarly, 1650 and 1160 were the PWM values corresponding to the maximum left and maximum right positions. Pixel_1+6 and pixel_2-6 correspond to the rightmost and leftmost positions of the line that can be detected by the line detection algorithm. Similar relations were used to adjust the speeds of dual DC motors to avoid slipping.
The control system that was used in the robot is a PID controller or proportional–integral–derivative controller which is a control loop feedback mechanism. It calculates an “error” value as the difference between a measured process variable and a desired set point. In this case the measured process variable is the current position of the black line and the set point is the desired position of the black line. Anti winding algorithm was applied to prevent the integral term exceed its maximum negative or maximum positive value.