桂花蒸

【ART-Pi】ART-Pi PC-like multimedia expansion board

 
Overview

Introduction

This project is an expansion board for RT-Thread’s open source hardware ART-Pi. Expanded VGA and USB interfaces for ART-Pi. It can be used to connect a VGA monitor and keyboard to turn ART-Pi into a "PC"-like device. Or as a simple GUI development platform.

characteristic

  • Supports standard VGA interface (D-Sub), driven by LTDC controller
  • Supports up to XGA (1024x768) resolution
  • Supports DDC protocol, using hardware I2C controller, which can be used to provide EDID support
  • Dedicated video DAC, supporting up to 16 million colors (16.7M colors, RGB888)
  • Proprietary ESD protection on D-Sub to prevent electrostatic damage
  • Support USB 2.0 Full-Speed
  • The USB interface has dedicated ESD protection and over-current protection, as well as an over-current protection indicator light.
  • An additional power interface can power the expansion board and ART-Pi, with an input voltage of 7~12V
  • Through-hole expansion board, can continue to connect other expansion board modules

Detailed explanation of the principle

VGA

First of all, I strongly recommend everyone to watch this video, link: This may be the worst graphics card in the world . In this video, the author made a "graphics card" on a breadboard that can output a VGA signal. The author's explanation of the VGA signal is very simple and easy to understand, and is suitable for friends who have never understood VGA.

VGA signals include control signals (synchronization signals) and data signals. For our project, the first thing we need to pay attention to is the timing of the VGA control signals:

image.png

This timing diagram also explains the specific working method of VGA: the displayed content is sent line by line. After the content of a line is sent, the display device is notified of the content of the current line through a pulse called Horizontal Sync Pulse (HSP). The transfer is complete, then the next line is transferred. This cycle continues until the entire screen's content is transmitted and a Vertical Sync Pulse (VSP) pulse is sent. At this point, one frame is transmitted. Then continue transmitting the next frame.

VGA is a pure analog signal, which is prepared for CRT monitors. The display device determines the format of the signal entirely through the length of the two pulses HSP and VSP and the interval between the pulses. Because there is no digital communication process, the timing accuracy is required to be high. And due to the limitations of the display, in fact we cannot freely determine the signal length and spacing of HSP and VSP. Here are some commonly used signal formats:

image.png

Knowing the format of the signal, how can we generate accurate signal timing? Some students may say that you can just use a timer. This is indeed a method, but it is more troublesome to implement. Here we do not use it but use LTDC, a peripheral of ART-Pi's main control STM32H750XB, to generate VGA signals.

The full name of LTDC is "LCD-TFT display controller", which is the LCD display device controller. As the name implies, LTDC is used to control the peripherals of LCD liquid crystal displays. It has two working modes: DE mode and HV mode. The difference is that DE mode only uses DE signals for frame synchronization, while HV mode requires the use of HSYNC and VSYNC two signals to synchronize data frames.

After seeing how VGA signals work, I believe you will be familiar with HSYNC and VSYNC in HV mode. In fact, the working principle of LTDC's HV mode is highly consistent with the principle of VGA signal. It's just that LTDC transmits digital signals. This is also the theoretical basis for us to use LTDC to generate VGA signals.

Let’s look at the signal timing diagram of LTDC (HV mode):

image.png

At first glance, it seems that the timing of the VGA signal is completely different, but in fact, you will find out if you analyze it carefully. Its working principle is exactly the same as that of VGA, except that the SYNC PULSE is drawn to the front in this picture, so it just looks a little inconsistent.

So we only need to adjust the parameter timing of the LTDC controller to be consistent with the expected VGA signal timing to generate an accurate VGA synchronization signal. The next question is, which signal format do we use? Going back to the commonly used VGA signal format table, you can see that the frequencies of most signals are non-integer multiples, and generating non-integer multiples of signals is a very laborious task. We need to do it in the clock configuration of STM32 Just make a bigger compromise. Therefore, the most suitable signal is this:

image.png

A 40MHz signal is a very easy to implement round number. Then the resolution and refresh rate of 800x600@60Hz are also more suitable.

Then we can view the specific parameters of this signal format:

image.png

We need to use these parameters to configure the LTDC controller of STM32H750. It is recommended to configure via CubeMX here, which is convenient and less error-prone:

image.pngimage.png

The other configurations of the LTDC are the same as those used when using the LCD screen normally, and will not be described again here.

The control signal meets the requirements, and the next step is to send the display content. LTDC sends digital signals, while VGA display devices need to receive analog signals. Obviously, we need a DAC (digital-to-analog converter) to do this job.

Let’s first look at the standards of the VGA physical interface:

image.png

Among them, HSYNC and VSYNC are synchronization signals. We have just introduced them. Now we need to focus on the three pins labeled RGB, Pin1, 2, and 3. These three pins are used to send the corresponding color data. signal pin.

We notice that the signal has an impedance of 75Ω at the terminal and source ends. In a simple model, we can think that the signal has a resistance of 75Ω to ground. Then the voltage range of the signal is 0~0.7V. That is to say, we need to convert the digital signals of the RGB channels into 0~0.7V analog signals and transmit them through these three lines.

We can use a resistor voltage divider network to convert RGB565 digital signals to analog signals. This method is low-cost but the display effect is not very ideal. In order to improve the image quality, we can use ADV7123, a dedicated VGA signal DAC, to convert digital signals to analog signals.

image.png

Relative to using a resistor network to achieve digital-to-analog conversion. ADV7123 requires an additional pixel clock signal for data synchronization. We can directly use the pixel clock signal output by the LTDC controller. Then there is nothing more to say. Just design the circuit according to the ADV7123 data sheet. The final circuit is as follows:

image.png

Since it needs to be connected to an external VGA device and considering the possible ESD damage, here we add an additional dedicated ESD protection chip before the DAC and the final VGA output terminal.



image.png

image.png

At this point, we have completed all preparations for outputting VGA signals.

USB

In order to connect a USB keyboard, we need a USB Host interface. There’s actually not much to say about this, there’s a lot of information online. The electrical connection is also relatively simple.

Since the USB interface of the STM32H750 is relatively fragile, in order to protect against possible short circuits and electrostatic breakdown, a dedicated ESD protection chip and USB short circuit protection chip are added here.

image.png

power supply

Considering that the power supply of the ART-Pi body may be insufficient, an additional power supply circuit is added here with reverse connection protection and over-current protection, which can directly accept an input voltage of 6~12V to power the ART-Pi and expansion board.

image.png

PCB design

The PCB directly uses the form factor of ART-Pi. It should be noted that since the LTDC interface of the ART-Pi is led out through the FPC socket, the LTDC interface of the expansion board will be connected to the ART-Pi body using an FPC soft cable.

Final design renderings:

image.png

image.png

Software description

The design idea of ​​this expansion board is to provide the hardware foundation for realizing a PC-like device similar to ColorMixmate (of course, you can also use this expansion board not according to my design idea at all). In the current Demo, I implemented a small console, transplanted a command line library, and embedded a small BASIC interpreter. In the command line environment, you can use some of my built-in commands to mount the SD card, switch file paths, view pictures, and play videos. In a BASIC environment, you can code using the BASIC language. I implemented the control of GPIO in the BASIC environment, so you can also use BASIC to implement some basic GPIO operations.

The Demo code was developed in trueStudio and is completely open source. Please jump to the attachment to download.

Instructions for using built-in commands in shell environment

  • help effect: List all supported commands
  • mount effect: mount the SD card. Note that before using any file operation, you must first execute the mount command to mount the SD card.
  • clear effect: clear the screen
  • ls effect: List all files in the current directory
  • cd [path] Effect: enter/exit directory. Example: Enter the test subdirectory: cd test; Return to the root directory: cd /; Return to the upper directory:cd ..
  • op [file] Effect: Open the file. Currently, it only supports viewing JPEG images and playing MJPEG encoded AVI format videos. File names starting with a number need to be enclosed in double quotation marks. Example: Open the picture 123.jpg (note that the quotation marks cannot be missing): op "123.jpg"; Open the video aerith.avi: op aerith.avi JPEG picture file limit: no larger than the screen resolution (800x600) AVI video file limit : MJPEG encoding, no audio, below 25FPS, resolution no higher than 800x600
  • basic Enter the BASIC environment. Note that you cannot return to the command line environment after entering the BASIC environment.

Add your own commands to the command line environment

First, we need to create an entry function for the command. The function can be one of the following types:

main function form

Using this approach, an example of a function definition is as follows:

int func(int argc, char *agrv[])
{
    printf("%dparameter(s)
", argc);
    for (char i = 1; i < argc; i++)
    {
        printf("%s
", argv[i]);
    }
}

Then, use the macro registration command outside the function:

SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), testcmd, func, test);

The first parameter is a fixed form, the second parameter is the command name, that is, the name of the command executed on the command line, the third parameter is the command entry function name, and the fourth parameter is the comment.

Then we can call this command in the terminal:

letter:/$ testcmd "hello world"
2 parameter(s)
hello world

Ordinary C function form

Using this method, the shell will automatically convert the parameters. Currently, it supports automatic processing of binary, octal, decimal, and hexadecimal integers, characters, and strings. Examples are as follows:

int func(int i, char ch, char *str)
{
    printf("input int: %d, char: %c, string: %s
", i, ch, str);
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC), func, func, test);

Terminal call

letter:/$ func 666 'A' "hello world"
input int: 666, char: A, string: hello world

GPIO operations in BASIC environment

The current Demo only implements the output function of GPIO. Before operating a certain GPIO, you need to use the following command to set the corresponding GPIO to output mode:

PINMODE 2,1

The first parameter is the GPIO number, the second parameter is the mode, 1 indicates the output mode. The corresponding relationship between the GPIO number and the real GPIO is defined in the host.c file:

static const BASICPinDef supportedOutputPins[] = {
        {2,  GPIOH, GPIO_PIN_12},
        {3,  GPIOH, GPIO_PIN_11},
        {4,  GPIOA, GPIO_PIN_8},
        {17, GPIOA, GPIO_PIN_15},
        {22, GPIOH, GPIO_PIN_13},
        {10, GPIOI, GPIO_PIN_3},
        {9,  GPIOI, GPIO_PIN_2},
        {11, GPIOI, GPIO_PIN_1},
        {5,  GPIOH, GPIO_PIN_7},
        {6,  GPIOH, GPIO_PIN_9},
        {13, GPIOB, GPIO_PIN_13},
        {19, GPIOI, GPIO_PIN_7},
        {26, GPIOI, GPIO_PIN_4},
};

If you want to add GPIO support, you can also add it in this array.

After setting the output mode, you can use the following command to control the output status of the GPIO

PIN 2,1

The first parameter is the GPIO number, the second parameter is the output level, 0 means low level, 1 means high level.

Finished product renderings display

PCB empty board diagram

image.png

Welding finished product picture

image.png

image.png

instructions

image.png

image.png

Basic command line environment

image.png

display image

image.png

play video

image.png

BASIC environment

image.png

Control GPIO via BASIC code

image.png

参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-06-20 04:50:54

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号