CCD module-Reading data (ADC)

The tutorial combines OLED and serial port to display the data output by CCD module.

Hardware connection

image-20240825213503957

Since we have configured a special connection line, we only need to install it to the corresponding interface:

PeripheralsDevelopment board
CCD: VCC3.3V
CCD: AOPA4
CCD: SLKPB4
CCD: SIPB5
CCD: GNDGND

Control principle

image-20240808115819550

PeripheralsDescription
CCD: VCCPower supply pin: 3.3V-5V
CCD: AOGray value output pin: analog output
CCD: CLKClock pin, determines the exposure time and controls the output of pixel gray value.
CCD: SIControls the acquisition and output of pixel gray value.
CCD: GNDPower supply pin: GND

Working principle

Acquisition timing diagram:

image-20240808114920107

Black line detected

The corresponding grayscale value is low;

White line detected

The corresponding grayscale value is high.

Software configuration

Pin definition

Main control chipPinMain function (after reset)Default multiplexing functionRedefine function
STM32F103RCT6PA4PA4SPI1_NSS/USART2_CK/DAC_OUT1/ADC12_IN4 
STM32F103RCT6PB4NJTRSTSPI3_MISOPB4/TIM3_CH1/SPI1_MISO
STM32F103RCT6PB5PB5I2C1_SMBA/SPI3_MOSI/I2S3_SDTIM3_CH2/SPI1_MOSI

Software code

We need to configure the pins differently according to the function of the CCD pins.

Control function

The tutorial only briefly introduces the code, you can open the project source code to read the details.

ccd_Init

Get_Adc_CCD

RD_TSL

Find_CCD_Zhongzhi

CCD_Get_ADC_128X32

OLED_Show_CCD_Image

Experimental phenomenon

The CCD.hex file generated by the project compilation is located in the OBJ folder of the CCD project. Find the CCD.hex file corresponding to the project and use the FlyMcu software to download the program into the development board.

After the program is successfully downloaded: OLED and serial port display the data output by the CCD module, and OLED displays the CCD module data in the form of a curve.

image-20240827181344627