Introduction: STONE Display Module With Camera Picture Display

About: I am an embedded engineer working in Beijing. I like to share my projects with you.

This article will introduce ov7670 camera module connection with STONE LCD.

displaying camera images through a serial display module. The methods and code described in this article are for individual developer testing only and cannot guarantee commercial stability. ov7670 camera module connection with STONE LCD, main function:

1. The display screen displays the pictures collected by the camera in real time

2. Click the button to shoot an image and save it to the TF card

3. Switch colors and grayscale

4. Resolution can be switched (240*320, 240*240, 160*160, 80*80)

5. You can switch to the mode of viewing pictures

6. You can browse the last picture

7. You can browse to the next picture

Before proceeding with this project, let's take a look at what hardware modules are needed.

1. STONE 7-inch 800*480 resolution serial display module

2. STM32F103ZE development board

3. OV7670 camera module

4. A small amount of relevant wire We can first look at the pictures of the related hardware modules: STONE 7 "800*480 resolution serial display module

This development board has a number of integrated features:
1. Cotex-m3 core chip, STM32F103ZET6, 2. 144P pin 3. External crystal oscillator 8M, clock crystal oscillator 32768Hz 4. Standard 20P socket, JTAG interface, used for downloading debugging programs such as Jlink, Ulink and st-link 5. Standard 4P pin insertion, SWD interface, use 2-wire communication to debug and download the program 6. All I/O ports are used to insert needles for convenient experiment expansion 7. Usb-ttl serial port conversion circuit, realizing serial port communication of USB interface 8, automatic download adaptor circuit, use serial port download without frequent switching, a key to download MAX232 conversion circuit, suitable for external serial line 10. Integrated infrared receiver, user remote infrared receiving function 11, DS18B20 socket, directly inserted into the chip to achieve digital temperature measurement function 12, with clock backup battery, keep the clock and important information not lost power 13. EEPROM chip 24c02 to store common user information and use IIC for communication 14, FLASH chip W25Q64,8M memory, can store pictures, system data and other information 15. SPI mode SD card holder, TF card, PI communication 16. SDIO mode SD card holder, TF card, dedicated SDIO interface, high speed, stable. 17. RF24L01 socket for testing wireless communication (at least 2 machines are required) 18. 3-way normal key input function, man-machine interface 19, 1 way wake up button, used to wake up from low power consumption or standby mode 20. LED lamp of the 2-way user, making basic state and operation instructions 21, 1 USB device interface, used for debugging USB device functions, such as card reader, USB serial port functions 22. TFT color screen LCD interface, including touch screen interface, can be directly inserted into the supporting screen 23. Camera reserved interface, supporting camera module to achieve video presentation function 24. No. 1 buzzer 25, 1 touch button function 26. Self-recovery fuse to protect the computer from damage 27. Reset button 28. Power indicator Choose to insert the pin 30. Select the pin with VREF reference voltage 31, CAN, USB switch pin 32. 3.3v outboard power supply pin insertion 33. 5V external expansion power supply pin insertion

But in fact, we only use his camera interface and serial port and TF card interface

Step 1: STONE TFT-LCD Display Module

STONE stvc070wt-01 is a 7-inch display module with a resolution of 800*480.This display module can be purchased from STONE's official website or from STONE's online shopping platform link.

The communication mode of STONE stvc070wt-01 is uart-rs232 and uart-ttl.In this project, I used uart-ttl communication mode. Display module development way is simple, the MCU only need through UART send instruction to the STONE, the contents of the display module, control is ok, the same principle, when a user touch STONE display screen, display module and related instructions sent to MCU through UART, and then MCU to control the corresponding devices (such as motor rotation, light switch, etc.).

7 inches STONE STVC070WT-01

The materials provided by the manufacturer are as follows:

Main packing list:
1. Transfer connection and connection

2. Usb-ttl adapter board

3. Usb flash drive (including development materials)

4. Micro USB cable

5. USB transfer board

6. STONE stvc070wt-01 display module

STONE Display module profile
Stvc070wt-01 is a TFT display and touch controller.It includes processor, control program, driver, flash, RS232/RS485/TTL port, touch screen, power supply, etc., is a powerful display system

The operating system is simple and can be controlled by any single chip microcomputer.Stvc070wt-01 can be used to perform all basic functions, such as text display, image display, curve display, touch function, video and audio function, etc.

- built-in Cortex CPU and drivers

- can be controlled by any single chip microcomputer

- display pictures/text/curves

- 65536 color TFT display

- can be touched

- RS232/ RS485/ TTL UART interface and USB port

- wide voltage range

STVC070WT-01 Display module control principle
The tft-lcd module communicates with the MCU by command (hexadecimal), and the MCU will work according to the command it receives.

Three steps are required to complete the firmware development of the STONE display module
Using STONE's tft-lcd module requires only 3 steps:

1. Design a set of man-machine pictures (UI).

2. Uart-ttl directly connects to the customer's MCU.

3. Write a simple program, by the MCU through command control tft-lcd module.(hexadecimal code).

The serial command frame of the TFT LCD module consists of five data blocks, all of which are represented in hexadecimal format.The way data is transferred to MSB.For example, for 0x1234, 0x12 is sent first, and then 0x34 is sent.

Application scenarios of STONE TFT-LCD display module

The STONE display module is widely used in a variety of industrial applications, such as:
1. Medical beauty equipment

2. Engineering machinery and vehicle equipment

3. Electronic instruments

4. Industrial control system

5. Power industry

6. Civil electronic equipment

7. Automation equipment

8. Traffic.

Step 2: UI Picture Design

The user designs the UI using Photoshop or other software

The interface I designed is as follows:

The first picture is the main screen picture, and the second picture is the effect when the button is pressed.

Use the TOOL2019 software set to generate the LCD module configuration file

Click the arrow button to generate the configuration file, and then download the configuration file to the display module to display the UI interface we designed.
I won't go into the details of this part of the content and tutorial, you can go to the STONE website to download a very detailed tutorial. In addition, we also need to design an identical picture as the effect when the button is pressed. We just need to change the color of the button position to the following table.

Wiring and welding
In the previous content, I introduced the relevant development operation of STONE stvc070wt-01. In the following content, I will focus on the STM32 MCU and the VO7670 camera.Before we do that, let's take a look at how the hardware part of the project connects.

A complete wiring diagram for the STONE project

OV7670 module -- STM32 development board:
OV_D0 ~ D7 -- -- -- -- -- -- -- -- -- -- - PC0 ~ 7

OV_SCL -- -- -- -- -- -- -- -- -- -- -- -- PD3

OV_SDA -- -- -- -- -- -- -- -- -- -- -- -- PG13

OV_VSYNC -- -- -- -- -- -- -- -- -- -- -- -- PA8

FIFO_RRST -- -- -- -- -- -- -- -- -- -- - PG14

FIFO_OE -- -- -- -- -- -- -- -- -- -- - PG15

FIFO_WRST -- -- -- -- -- -- -- -- -- -- -- -- PD6

FIFO_WEN -- -- -- -- -- -- -- -- -- -- -- -- PB3

FIFO_RCLK -- -- -- -- -- -- -- -- -- -- -- -- PB4

The power adapter is 12V and needs to power the STONE stvc070wt-01 display module and power the MCU module and OV7670 through the dc-dc step-down to 5 volts.

Accessories used in the project
Main accessories are: 1. STM32F103ZE development board 2. Dc-dc step-down module 3. UART switching Since the default communication mode of STONE stvc070wt-01 is uart-ttl, we do not need the interface of RS232 for switching connection, and remove the interface of RS232:

Welding
By welding these parts together, the effect is as follows:

When this part is ready, you can write the program for the MCU.

OV7670 camera module

OV7670 is a kind of image sensor, the operating temperature is -30℃-70℃, the analog voltage is 2.5-3.0v, the photosensitive array is 640*480, and the power consumption is 60mW/15fps.Less than 20uA in dormancy.
Small size, low operating voltage, providing all the features of a single VGA camera and image processor.Through SCCB bus control, you can input the whole frame, sub-sampling, window and other ways of various resolution 8-bit image data.The product's VGA image reaches a maximum of 30 frames per second.Users have complete control over image quality, data format and transmission.All image processing functions including gamma curve, white balance, saturation, chroma, etc. can be programmed through the SCCB interface.By reducing or eliminating optical or electronic defects such as fixed pattern noise, tail support, floating and so on, image quality can be improved to obtain clear and stable color images. OV7670 is a 1/6-inch CMOS VGA image sensor produced by OV (OmniVision).The sensing The device is small in size, low in working voltage, and provides all the functions of a single VGA camera and image processor.Through SCCB bus control, you can output the whole frame, sub-sampling, window, and other ways of various resolution 8-bit image data.The product's VGA image reaches a maximum of 30 frames per second.Users have complete control over image quality, data format and transmission.All image processing processes including gamma curve, white balance, degree, color, etc. can be programmed through SCCB interface.OmmiVision image sensor USES unique sensor technology to improve the image quality by reducing or eliminating optical or electronic defects such as fixed pattern noise, tail support, floating, etc., to obtain clear and stable color images.

Features of OV7670 include:

1. High sensitivity, low voltage suitable for embedded applications

2. Standard SCCB interface, compatible with IIC interface

3. Support RawRGB, RGB(gbr4:2:2, RGB565/RGB555/RGB444), YUV(4:2:2) and YCbCr

4. Supports VGA, CIF, and all sizes from CIF to 40*30

5. Support automatic exposure control, automatic gain control, automatic white balance and automatic elimination of light streaks

6. Automatic black level calibration and other automatic control functions.At the same time support color saturation, hue, gamma, sharpness and other Settings.

7. Flash support

8. Supports image scaling Functional block diagram of OV7670:

The OV7670 sensor includes the following functional modules.
1. Image Array OV7670 has a total of 656*488 pixels, of which 640*480 are valid (i.e., effective pixels are 30W). 2. Video Timing Generator The sequence generator has the following functions: whole sequence control and frame rate generation (output in 7 different formats), internal signal generator 535 and distribution, frame rate timing, automatic exposure control, and output of external timing (VSYNC, HREF/HSYNC, and PCLK). 3. Analog signal Processing Analog signal processing all analog functions and includes: automatic gain (AGC) and automatic white balance (AWB). 4. A/D conversion (A/D) After the original signal passes through the analog processor module, it enters A 10-bit A/D converter via G and BR channels. The A/D converter operates at A frequency of 12M, fully synchronized with the pixel frequency (the conversion frequency is related to the frame rate). The A/D range product and A/D range control jointly set the A/D range and maximum, allowing the user to adjust the brightness of the image based on the application. Next, let's introduce the image data output format of OV7670.First, let's briefly introduce some definitions: VGA, that is, the output mode with a resolution of 640*480; QVGA, the output format with a resolution of 320*240, is the format we need in this chapter. QQVGA, that is, the output format with a resolution of 160*120; PCLK, or pixel clock, a PCLK clock, outputs one pixel (or half a pixel). VSYNC, the frame synchronization signal.HREF /HSYNC, the line synchronization signal. OV7670's image data output (via D[7:0]) is controlled in PCLK, VSYNC, and HREF/ HSYNC Below.First, take a look at the timing of the row output, as shown in the figure:

As can be seen from the figure above, the image data is output when the HREF is high, and when the HREF is high, when each PCLK
Clock, output a byte of data.For example, we use VGA timing, RGB565 format output, every 2 bytes constitute a pixel color (high bytes before, low bytes after), so that the output of each line has a total of 640*2 PCLK cycles, the output of 640*2 bytes. Frame timing (VGA mode) :

The figure above clearly shows the data output of OV7670 in VGA mode. Note the HSYNC and HREF in the figure
It's actually a signal from the same pin, but in different ways under different situations, we're using HREF in this chapter. Since the pixel clock (PCLK) of OV7670 can reach up to 24Mhz, we use the IO port of STM32F103ZET6 to directly grasp, which is very difficult and takes up a lot of CPU (IO port can be captured by reducing the output frequency of PCLK, but it is not recommended). In this project, I used RGB565 mode, and the image data captured was the original data of RGB, which was then transferred to the STONE display module through UART.

Step 3: TF Card Driver

The project also requires a TF card to store the images taken.

Because the TF card driver is too long, I will not post it here. You can search the relevant code on the network to use.

STM32F103ZE
There are a lot of information and development documents about this chip on the network, here is a brief introduction to this chip. This is the development board for STM32F103ZE:

I won't say much about this chip.The chip download code USES j-link, as shown in the figure below:

This is a simple version of j-link that only supports SWD debugging and downloading, not JTAG.But for STM32 chip development, SWD debugging is enough.
Download the code to the STM32 chip

Make sure the connection between j-link and STM32F103ZE is correct, and then the chip can be identified in the KEIL development environment:

Click the download button to download the code to the chip:

STM32 control code
The data receiving of the STONE display module can only receive 255 bytes at a time, while the image size of a single RGB565 data is 240*320*2=153600Byte= 153.6kb, so it needs to be subdistributed. In addition, due to the limitation of serial communication rate, the effect of picture real-time refresh is not very good.The serial port baud rate is configured to 921600, which is also the highest communication baud rate for the STONE serial display module. Buttons and text in the display have corresponding addresses. In this project, the address of the display component is as follows:

TAKE PICTRUE BUTTON : 0X002A

COLOR&GRAY BUTTON : 0X002B

CHANGE RATION BUTTON:0X002C

PREV PICTURE BUTTON:0X002D

NEXT PICTURE BUTTON:0X002E

BROWSE BUTTON : 0X002F

Step 4: Running Effect