An4244 PDF
An4244 PDF
An4244 PDF
1 Introduction
1 2 3 4 5 6
Introduction.................................................................1 Camera signal interpretation.......................................2 Signal processing........................................................3 Software/Driver description........................................5 AO signal processing implementation........................8 Conclusion................................................................16
This application note explains how the Parallax TSL1401-DB camera works and how it can be used for the specific application of following a line for the Smart Car Race competition. This document includes tips and refers to the example code on how to process the signal from the camera on the MPC5604B microcontroller (MCU); the example code can be downloaded as AN4244SW from https:// www.freescale.com. The Parallax TSL1401-DB LineScan Camera Module consist of a CMOS linear sensor of 128 pixel array and a mounted lens of 7.9 mm, these provide a field of view equal to the subject distance. Some of the advantages of using this camera are the following: Simple and easy to use Frequency of capture can be manipulated by the user Enough definition for line following application Removable and interchangeable lens for different resolutions Besides the above benefits, the only disadvantage is the output signal of the camera is completely analog, which means the user has to be creative, to process this signal in order to make it understandable. This document provides two different methods to process this signal. There are many evaluation boards for the Parallax camera, which can be another inconvenience. For this case, a benchmark was done and Parallax BASIC Stamp DB-
Expander Daughter board-to-SIP or the Parallax Stamp 2pe Daughter board Extension Cable was found. These were found as the easiest to use from https://www.parallax.com. NOTE Rev 0 of this application note provides only the drivers as explained in the example code. A complete example using these drivers will be provided in the next revision of the application note.
How is light interpreted? As mentioned before, the camera is a combination of an image sensor (linear in this case) and a lens. The light that bounces from the environment enters through the lens, and the last one deflects light into the sensor. The sensor consists of a microscopic array of capacitors that gain charge depending on light intensity, therefore all pixel charge at the same time and the sensor releases each pixel value in one output signal one after the other until all pixel charges are released. The following image illustrates the process.
Signal processing
Because the camera is using a linear sensor it is impossible to gain a full view of the panorama in a single shot, therefore it only takes one line of the full panorama as shown in the next image. Here, the line to be captured is completely dependent on the distance to the lens as shown in Figure 2. Finally this image is released in an analog signal as shown in Figure 3.
For normal operation of the camera, the user needs to take care of the following signals only: CK (clock) SI (serial input) AO (analog output) where CK and SI are camera inputs and AO is a camera output. As mentioned before, the user can manipulate the frame speed of the camera by adjusting CK and SI signals. Faster is the CK frequency, the faster the camera releases the pixel values, and the closer each SI is from one another the faster each frame capture occur. It is important to understand, the faster the frame capture occur the lower each pixel gain charge. This leads to another important factor, the integration time. Integration time (Figure 4) is the time the pixels have to complete its charge. With very long integration time, the pixels will be saturated even if there is low light intensity in the environment, on the other hand with very short integration time the pixel will not gain charge even if there is excessive light on the environment. As it can be seen in Figure 4, after 18 clock cycles, the pixels begin to charge back again. After 129 clock cycles all pixels are released from the camera, this means, from that moment it can send another SI pulse to release AO signal again; but as mentioned before longer the cycle, the pixels will charge more and user will get better pixel quality.
3 Signal processing
Using Parallax TSL1401-DB Linescan Camera Module for line detection, Rev. 0, 01/2011
Freescale Semiconductor, Inc. 3
Signal processing
Using Parallax TSL1401-DB Linescan Camera Module for line detection, Rev. 0, 01/2011
4 Freescale Semiconductor, Inc.
Software/Driver description
4 Software/Driver description
SI and CK input pulse implementation Generation of SI and CK input pulses is implemented through Driver_Linear_Cam.c.
Parameters Return
Using Parallax TSL1401-DB Linescan Camera Module for line detection, Rev. 0, 01/2011
Freescale Semiconductor, Inc. 5
Software/Driver description
vfnInit_Emios_0_Mcb
vfnI nit_Emios_0_Opwm
Definitions involved
CAM_CNT_CHAN
CHANNEL_CK
CHANNEL_SI
PCR_EMIOS_0_tag
Focusing the camera Once the sensor is perfectly working the next step is to find the best position of the lens that will generate the clearest images. The best way to do it is using an oscilloscope (Figure 8); 1. Connect the SI and AO signals to the oscilloscope 2. Set the SI pulse so that it can be clearly seen and then trig the AO signal with the SI signal using the trig function 3. Fix the camera looking at a sheet of paper with a black line in the center 4. The image of the black line will appear on the oscilloscope screen 5. Screw the camera until you find the position where the line seems the clearest
Using Parallax TSL1401-DB Linescan Camera Module for line detection, Rev. 0, 01/2011
6 Freescale Semiconductor, Inc.
Software/Driver description
It is possible to change the lens of the camera. To search for the correct lens look for them as Board camera lens you will find the angle of view is measured in millimeters, which corresponds to the focal length. The angle of view depends on the focal length and the image plane (Figure 9); for the Parallax image sensor the image plane is of 1/3 so be sure to take this last number in count while making your decision.
Using Parallax TSL1401-DB Linescan Camera Module for line detection, Rev. 0, 01/2011
Freescale Semiconductor, Inc. 7
Using Parallax TSL1401-DB Linescan Camera Module for line detection, Rev. 0, 01/2011
8 Freescale Semiconductor, Inc.
Parameters
u8TolDelta
u8TolWidth
Return
1 0
Definitions involved
Using Parallax TSL1401-DB Linescan Camera Module for line detection, Rev. 0, 01/2011
Freescale Semiconductor, Inc. 9
u16width u16LineWidthMeasure
u16LineWidth u16Center
u8Frames
Parameters
Using Parallax TSL1401-DB Linescan Camera Module for line detection, Rev. 0, 01/2011
10 Freescale Semiconductor, Inc.
Definitions involved
PCR_EMIOS_0_tag
Variables involved
To obtain the values of line width and position of the line for the high level algorithm it is necessary to call functions u16_LineWidth() and u16_Center(). These are just return functions for the u16LineWidth and the u16Center variables.
2nd Method: Processing with ADC and CTU For this method, CTU (Cross Triggering Unit) will be used. As the CTU is in charge of triggering between eMIOS and ADC modules, it can start an ADC conversion when a eMIOS module flag is activated. As mentioned before; it is being generated as eMIOS OPWM with the same period of the clock pulse but out of phase for one fourth of its period. The purpose of placing this signal out of phase is to generate the cross triggering exactly where the pixel can be read (Figure 10). The CTU signal will trigger the ADC conversion when the pixel charge is in good conditions to be read, for this reason it is important to align these signals as shown in Figure 10. For capturing pixel values and developing useful data, use the vfnInit_CamLin_Adc() and u8Capture_Pixel_Values() functions of the Driver_Linear_Cam.c driver (Figure 11).
Using Parallax TSL1401-DB Linescan Camera Module for line detection, Rev. 0, 01/2011
Freescale Semiconductor, Inc. 11
Figure 10. Processing with ADC and CTU the AO input signal
Using Parallax TSL1401-DB Linescan Camera Module for line detection, Rev. 0, 01/2011
12 Freescale Semiconductor, Inc.
vfnInit_Emios_0_Saic_Ctu
vfnTrigger_Emios_Adc
vfnInit_Adc_Ctu
PCR_EMIOS_0_tag
PCR_ADC_tag
ADC_tag_CHANNEL
Using Parallax TSL1401-DB Linescan Camera Module for line detection, Rev. 0, 01/2011
Freescale Semiconductor, Inc. 13
Parameters Return
vfnSet_Duty_Opwm
Using Parallax TSL1401-DB Linescan Camera Module for line detection, Rev. 0, 01/2011
14 Freescale Semiconductor, Inc.
Variables involved
u8ScanDone
u8i
u16Center
u16corner1
u16corner2
Using Parallax TSL1401-DB Linescan Camera Module for line detection, Rev. 0, 01/2011
Freescale Semiconductor, Inc. 15
Conclusion
6 Conclusion
As mentioned before, the first implemented method has two advantages and two disadvantages; from these, calibration is a big issue as light (used as reference) is a variable dependant on the environment. So, bad illumination, shadows, etc, will be factors that make this task difficult. On the other hand, if the user can fix this calibration issue, the advantages make this method the best option. The second method is more comfortable because external processing is not necessary and will not face calibration issues. The only problem is the use of the ADC which means throughput is added to the application; this can pose a problem depending on the rest of the tasks and sensing stuff the user may require for other processes. Based on the above implementations and after using the camera signal processing feature of MPC5604B MCU, the user can notice the huge capabilities this family of microcontrollers offers.
Using Parallax TSL1401-DB Linescan Camera Module for line detection, Rev. 0, 01/2011
16 Freescale Semiconductor, Inc.
Information in this document is provided solely to enable system and sofware implementers to use Freescale Semiconductors products. There are no express or implied copyright licenses granted hereunder to design or fabricate any integrated circuits or integrated circuits based on the information in this document. Freescale Semiconductor reserves the right to make changes without further notice to any products herein. Freescale Semiconductor makes no warranty, representation, or guarantee regarding the suitability of its products for any particular purpose, nor does Freescale Semiconductor assume any liability arising out of the application or use of any product or circuit, and specifically disclaims any liability, including without limitation consequential or incidental damages. "Typical" parameters that may be provided in Freescale Semiconductor data sheets and/or specifications can and do vary in different applications and actual performance may vary over time. All operating parameters, including "Typicals", must be validated for each customer application by customer's technical experts. Freescale Semiconductor does not convey any license under its patent rights nor the rights of others. Freescale Semiconductor products are not designed, intended, or authorized for use as components in systems intended for surgical implant into the body, or other applications intended to support or sustain life, or for any other application in which failure of the Freescale Semiconductor product could create a situation where personal injury or death may occur. Should Buyer purchase or use Freescale Semiconductor products for any such unintended or unauthorized application, Buyer shall indemnify Freescale Semiconductor and its officers, employees, subsidiaries, affiliates, and distributors harmless against all claims, costs, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or unauthorized use, even if such claims alleges that Freescale Semiconductor was negligent regarding the design or manufacture of the part. RoHS-compliant and/or Pb-free versions of Freescale products have the functionality and electrical characteristics as their non-RoHS-complaint and/or non-Pb-free counterparts. For further information, see http://www.freescale.com or contact your Freescale sales representative. For information on Freescale's Environmental Products program, go to http://www.freescale.com/epp. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. 2011 Freescale Semiconductor, Inc.
Web Support:
http://www.freescale.com/support
Japan:
Freescale Semiconductor Japan Ltd. Headquarters ARCO Tower 15F 1-8-1, Shimo-Meguro, Meguro-ku, Tokyo 153-0064 Japan 0120 191014 or +81 3 5437 9125 support.japan@freescale.com
Asia/Pacific:
Freescale Semiconductor China Ltd. Exchange Building 23F No. 118 Jianguo Road Chaoyang District Beijing 100022 China +86 10 5879 8000 support.asia@freescale.com