newrudeman

LED full color dot matrix screen driver board

 
Overview

Full color LED dot matrix screen

Introduction

A simple full-color LED dot matrix screen program with clock, temperature, music spectrum, bad apple, full-color animation, text display and other functions

Hardware schematic
https://oshwhub.com/code504/led-quan-cai-dian-zhen-ping_copy_copy

Software source code
https://gitee.com/dma/full-color-led-screen

Video demonstration
https://www.bilibili.com/video/BV1t541127oo/

cover.jpg
pcb1.jpg
pcb2.jpg

Hardware description

Screen specifications

Size: 256mm * 128mm
Resolution: 64 * 32
Interface: HUB75
Specifications: P4, full color, 16 scan

peripherals

Clock chip: PCF8563
Temperature and humidity chip: SHT30
Microphone: MAX9814
Storage: Any model SPI NOR Flash

Reserve peripherals

VS1838B or compatible infrared receiving tubes are reserved for remote control operation.
Two commonly used packages of ESP8266 are reserved, which can be connected to the network to achieve richer functions.
Three power supply modes of USB, DC and binding posts
are reserved. 1 PWM is reserved. Can be connected to buzzer, etc.

other

Due to the epidemic, the LED diffuser I bought did not arrive, so I used an ordinary transparent plastic plate and a frosted plastic bag to make a temporary diffuser.
If the diameter of the LED is relatively large, buy a thicker diffuser. The specific effect needs to be adjusted by yourself.

As we all know, the price of the STM32F103 series of microcontrollers has skyrocketed since 2021, and now it is simply unaffordable. I made it with the inventory on hand. Here are two alternatives:

  1. Use the domestic GD32 series instead. I don’t have a GD32 series chip at the moment, so I can’t verify whether it can be replaced perfectly. Friends who have successfully replaced it are welcome to leave a message in the comment area to share with everyone.
  2. Use STM32 to replace other PIN to PIN compatible chips, such as STM32F401 and STM32F411, which are almost completely compatible with STM32F103. Only a few pins are different. Moreover, STM32F4 has stronger performance than STM32F1 and can do more complex programs. I don’t have an F4 chip on hand at the moment, and I welcome friends who have successfully replaced it to share it with you. (The current (2022.5.1) price of these two chips of F4 is about 35 yuan)
  3. Use other chips to make another one (dog head.jpg)

Software description

Software Architecture

Serial port 1 debugging interface
Serial port 2 reserves ESP8266
ADC0 photoresistor to realize automatic brightness
ADC1 audio input
Timer 1 interrupts at 24kHz frequency, responsible for ADC audio sampling
Timer 3 interrupts at 100Hz frequency, responsible for key scanning and screen refresh

music spectrum

  1. Audio input
    There are two ways of audio input: 3.5mm audio interface input and microphone collection input.
    The advantages and disadvantages of these two solutions are obvious.
    The signal input from the 3.5mm interface is very clean and has no noise, but when you want to listen to music, you must plug in the audio cable to your mobile phone or computer. At the same time, you need a 1/2 adapter to output one channel to the dot matrix screen and the other to the dot matrix screen. Headphones or speakers are more troublesome to use, not to mention that most mobile phones now do not have such "very advanced" audio interfaces.
    Microphone collection is not so troublesome and can be used at any time. The disadvantage is that the surrounding environmental noise will also be collected.
    What I am using here is a microphone collection solution. Remember to use MAX9814 or other similar microphone modules with automatic gain function. This will save you a lot of trouble. Never use an ordinary microphone module, that is the beginning of your nightmare.
  2. ADC sampling
    The sampling rate of general music is 44100Hz. Generally speaking, high-frequency sounds above 10KHz will make the listening experience richer, but the energy carried by this part of the sound is relatively small, the amplitude in the spectrum is also relatively small, and the visual effect is not good. Okay, not to mention that using a microphone to collect will also introduce more noise. So here I mainly collect audio signals below 10KHz. According to the Nyquist sampling theorem, the sampling rate should not be less than 20KHz. The sampling rate frequency here is Set to 24KHz. Spectral aliasing will occur for signals above 24KHz. A reasonable processing method is to add a window function, such as a Hamming window or a Hann window. This will introduce additional calculations. I tried it without adding a window and the effect was OK, so this is A lazy step.
  3. fft performance optimization
    STM32F1 does not have an FPU, so the performance of floating point operations is very poor. Here, the kissfft library is simply configured, using 256 points of sampling, the data format is int16, and one fft takes less than 1ms.
  4. The result of optimizing
    fft by square root operation cannot be used directly, and modular operation must be performed. Optimization is also required here. The refresh rate of the screen is 100fps, which means 100 * 64 square root operations are performed per second. The math.h function performs very poor performance in performing square root calculations, directly dragging the frame rate below 50fps, and the visual effect feels laggy. Therefore, the Newton iteration method is used here to perform the square root. The integer square root error may not converge to the required accuracy, but it does not matter. The spectrum is mainly about visual effects, so very precise calculation results are not required.
  5. Logarithmic operation optimizes
    the Y coordinate of the spectrum display to take the logarithm for display. Also in order to avoid floating point operations, here it is changed to find the position of the highest bit of the integer 1, which is equivalent to taking the logarithm with 2 as the base, and then calculating the result After some proper processing, you can get good visual effects.

How to generate animation

Prerequisite: Know basic command line operations

  1. Prepare ffmpeg
    to download the release version of the corresponding system from the ffmpeg official website (https://www.ffmpeg.org/download.html). Remember it is the release version. Do not download the source code.
  2. Prepare video
    . Prepare any video. The following command will automatically convert the video file into a large number of BMP files.
    .ffmpeg.exe -i video.mp4 -vf scale=48:32 -frames 400 %04d.bmp
    Here is a brief explanation of these command parameters.
    -i video.mp4The file name to be converted
    -vf scale=48:32is the video scaling size. My screen is 64x32. Suppose I want to convert a 4:3 The video will fill the screen without stretching. Simply calculate the length and width after scaling, which is 48x32.
    -frames 400N frames before conversion.
    %04d.bmpOutput file name. See
    more detailed usage ffmpeg.exe -help fullyourself.
  3. bmp to format that can be played by microcontroller.
    Use my little tool https://gitee.com/dma/bmp_to_bitmap.
    It can batch convert bmp pictures to the specified format. For specific usage, see the introduction. If you are not happy with it, just change it yourself.
  4. The programming
    code reserves the functions of erasing flash and programming flash. When entering the command, remember to enter
    the serial port input to erase_spi()erase the chip, wait for the erasure to complete,
    serial port input write_spi(), and then use the send file function of the serial port tool to send the bin file generated in the previous step.
  5. Play
    Do it yourself (dog head.jpg)

font

The fonts are all PCtoLCD2002generated using , and the configuration is: negative code, reverse (low-end first), column-row type, and the character table is sorted according to GB2312 or GBK encoding.
If you don’t use many characters, you can just generate the necessary Chinese characters like this project. Write the characters directly into the microcontroller.
If you want to display a large number of characters, it is recommended to generate a complete GB2312 or GBK font library, put it in an external flash, and implement the search function of the font library yourself.

Refresh rate test

Test conditions:
MCU frequency: 72MHz
Screen color: pure white
Color mode: RGB565
Turn off all interrupts, cycle and refresh the screen 1000 times, time-consuming

brightness time consuming
1 4889ms
2 4930ms
3 4972ms
4 5013ms
5 5054ms
6 5096ms
7 5147ms
8 5179ms
9 5220ms
10 5261ms
15 5468ms
20 5675ms
30 6088ms
40 6520ms
50 6915ms

For indoor use, a screen brightness between 1 and 10 is sufficient. Higher brightness requires greater current, and the LED heats up more seriously.

other instructions

Whether to use MicroLIB

This project code is compatible with or without MicroLIB. If there are no special applications, it is recommended to use MicroLIB. Without MicroLIB, the code size will be larger after compilation. The specific size depends on how many standard library functions are used.

The most common problem of not using MicroLIB:
Error: L6200E: Symbol __stdout multiply defined (by retarget.o and stdio.o).
For solutions, see:
https://developer.arm.com/documentation/ka003082/latest and the chapter
in this article https://developer.arm.com/documentation/ka003082/latestRESOLUTION FOR SEMIHOSTING ISSUE

Display picture has color cast

Different LEDs have different specifications, and there will definitely be color differences compared with the monitor. If you want to get a better picture display effect, you need to manually adjust the brightness, chroma, gamma, etc. of the picture on the computer, and then put the adjusted image on the dot matrix screen. displayed, repeat this process until you are satisfied. If you have the ability, you can develop the function of adjusting the image on the microcontroller yourself.

About driving a larger dot matrix screen

When the refresh rate of the actual test dot matrix screen is lower than 50Hz, the flicker is obvious and uncomfortable for the eyes. You can make a simple estimate based on the refresh rate test results above. For example, assuming that STM32F1 is used to drive an 80x40 dot matrix screen, it takes approximately (80 * 40) / (64 * 32) * 4.889 = 7.76 ms to refresh one screen when the brightness is 1. If you want to drive a higher-resolution dot matrix screen, you need to optimize the code and replace it with a newer and more powerful microcontroller.

参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-06-18 22:06:41

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号