Mounting of camera is problem for everyones, but i put here some hints to control:
- Read datasheet of camera. Especially "Integration time" part.
- Integration time depends on distance from ground and quality of lighting. I show how change integration time in code below.
- Power supply for camera has to be 3.3V. Why? Because reference in AD converter is 3.3V. With 5V power supply AD converter can't work correctly. That means, that we can't use supply output on "Motor driver board", but we must remove Vcc and GND cable from camera connector and put them on 3.3V power suppy, for example on J8 connector on our CPU board, pin 2 for Vcc and 16 for GND. It works, i tested and using this modification.
- Optics of camera is baaad. Deal with it or make new.
- Problem of stock optic - few pixels on edges of array aren't well lighted. Best solution is mount camera, set high above ground and with osciloscope focus optic. Then we can "cut" bad pixels in program. 5-20 on both edges.
- How to connect osciloscope to camera? Just connect one probe to "AOUT" and "GND" of camera and second probe to "SI" as trigger. But "SI" is not necessary (With good osciloscope :-)).
And somethink about wiring camera:
- Connect "AOUT" straightly to input of AD converter.
- Connect "SI" and "CLK" straightly to outputs on CPU board.
- Use 3.3V power supply.
Here is source code, which is saving data from AD converter into array:
short int get_CAMERA(void)
{
short int delay_us = 20;
short int i = 0;
GPIOC_PSOR=PORTC12; //SI set
_delay_us(delay_us);
GPIOC_PSOR=PORTC5; //CLK set
_delay_us(delay_us);
GPIOC_PCOR=PORTC12; //SI reset
camera_line1_data[i] = get_ADVALUE(); //Save data from AD converter to array camera_line1_data
GPIOC_PCOR=PORTC5; //CLK reset
for (i = 1; i<128; i++)
{
GPIOC_PSOR=PORTC5; //CLK set
camera_line1_data[i] = get_ADVALUE();
GPIOC_PCOR=PORTC5; //CLK reset
}
_delay_us(delay_us);
GPIOC_PSOR=PORTC5; //CLK set
_delay_us(delay_us);
GPIOC_PCOR=PORTC5; //CLK reset
_delay_ms(5); //Here i can change INTEGRATION TIME
return(1);
}
This important image. It show to us how we must generate impulses to camera:
Few more things to integration time... We must realized, that camera is sending data from previous step, from previous integration!
Maximum of integration time: Maximum time between "SI" pulses is 100ms. Verify that with osciloscope. Bigger integration time - more light into camera.
And code of get_ADVALUE() function:
short int get_ADVALUE(void)
{
ADC0_SC1A = ADC_SC1_ADCH(8); //Trigger - start AD conversion
while((ADC0_SC1A & ADC_SC1_COCO_MASK) == 0)
{
}
return(ADC0_RA); //Return digital value of analog input
}
And this is one of ways how to control one line camera in Freescale Cup :-).
Češtin je tvuj klysnobík
OdpovědětVymazat