兰博

#The 3rd LiChuang Competition# LCD screen human-machine controller that can be quickly developed with C code

 
Overview

【Contents to be filled in during the registration phase】
1.
Name of the contestant (required):
Mr. Li
2.
Name of the unit or school (optional):
Beijing Aibozhi Electronic Technology Co., Ltd.
3.
Current position or title (optional):
Chief Engineer
4.
Name of the entry (required):
LCD human-machine controller that can be quickly developed using C code
5.
Briefly describe your idea and work (required):
With the advancement of the Internet of Things, many electrical appliances have been upgraded to smart appliances, and smart appliances require a screen that can display more complex information and control. This has led to the emergence of a special industry, namely the UI system; however, the current UI system is either very costly or very difficult to develop, so we are working to solve this problem; you can understand it as replacing the previous 4 86 computers are integrated into a very small device with a good development system and a very cheap price, so that they can enter the industrial chain for mass production;
   the core of this product is to find a script interpreter. On the same screen, users can upload different scripts to display different applications; with the corresponding mass production program, products with complex interfaces can be quickly produced;
I thought it was not difficult to make such a product, after all, there are scripting languages ​​​​such as lua and miniPython. If we use chips similar to the stm32f429 series, it can be easily realized, but it has no commercial value. At most, it can be regarded as a scientific research and development project, because the final selling price of this screen after mass production will be nearly 200 yuan due to the production cost; because Therefore, our goal is to complete such functions on an MCU that costs less than 10 yuan; (If the SDIO driver TF card and file reading and writing are compressed, it can be compressed to a chip of about 5 yuan)
Our product is positioned in industrial control, that is, the fragmentation problem caused by the continuous allocation and recycling of MCU memory must be solved, otherwise it will not work for a long time; secondly, the stringent requirements for memory (RAM) have created an unprecedented one. One of our main requirements is that no matter how complex the program you write is, how long the code is, or whether there is one interface or 100 interfaces, the required RAM memory must be certain. It cannot be said that a large number of interfaces requires a large RAM demand. For this reason, we spent the previous 4 versions, which took 4 years. After years of development, we have the current kernel version. During this period, we deeply understand that "without core technology, there is no product
. "
Well, let's talk about the product: first of all, the entire module has 2 serial ports and 6 IO ports, with a 3.5-inch 480*320 touch screen (other sizes of screens are also available). One of the serial ports is connected to the user's microcontroller or PLC, which can transmit input and output data and perform script parsing on various protocols; the other serial port is connected to ESP8266 or NBiot; the 6 IOs can set output, input, and AD input by themselves, and can be controlled by code;
  in terms of software writing, we provide host computer development, which can be directly developed based on the host computer, and the code is very simple, for example:
    class b1=loadcom(button); //Load button control
    void b1.onclick() //Button pressed event
    { gpio(1,1); //GPIO No. 1 is turned on and outputs a high level
    }
   start(); //Interface starts and starts running
  At the beginning, we provide a large number of buttons, icons, menus, dynamic GIFs, etc.
, selection items, and many other UI components are available for users to use. More importantly, all UI components are also developed directly from scripts and support non-source code delivery after compilation. In this way, everyone can quickly create a large number of controls in the entire ecosystem. In other words, if there are any unsatisfied needs, you can design your own controls. The development of controls is also very simple. Basically, GD statements are used to complete static display and dynamic display of data, as well as to process the display of mouse events. It is very convenient.
In software development, users only need to drag the required controls to the screen, set the corresponding properties, and then write the processing code for the corresponding events after the operation. After encapsulation, it can also become an event of a certain control; for those who need to expand IO control, they only need to upload the data packet, and the interface will automatically refresh the display through data binding logic, without writing code;
this project takes all commercial factors into consideration in its design, such as mass production, code compilation encryption, anti-copying and other factors, and the cost control is relatively good. The final finished module of about 3.5-inch screen may cost just over 100 yuan (the latest calculation shows that if funds are found and SIP-level encapsulation is carried out, the sales price can be around 70 yuan with a production volume of 10K), which is very suitable for application in the industrial chain of various products; it truly achieves "the convenience of development board and the price of core board";
6.
Materials sold in LiChuang Mall to be used (required):
https://item.szlcsc.com/142738.html GD32f303rct6
https://item.szlcsc.com/175500.html 25Q64
https://item.szlcsc.com/19779.html xpt2046
7.
Materials not sold in LiChuang Mall or other supplements to be used (required):
a 3.5-inch LCD screen
8.
Name of the EDA tool software to be used (required):
LiChuang EDA for drawing PCB
[Contents to be filled in when the work is officially published (entering the design stage after successful registration)]
1. Introduction to the work
, for example, can include but is not limited to the following:
1. Pictures of the appearance of the whole machine or pictures of the welded and assembled PCBA;
  2. The research background, purpose and function, and market application prospects of the work;
        see the project statement;
3. What highlights can be reflected in the work in terms of innovation, fun, practicality and even public welfare?
I have already mentioned it in the project statement, and I would like to emphasize it again here. Our main innovation lies in the technological innovation in the ecosystem. In other words, the popularization of hardware and software equipment is very difficult mainly because it requires users to have a high starting level. If we can significantly lower the threshold for users, it will be an immortal product, such as
Micro:Bit
Development board, has a huge user base, but its disadvantage is also exposed, that is, the price is too expensive, the market is defined as the teaching market, no one will use micro:bit in actual product design; our approach is different, first of all, we use industrial chain integration to reduce costs, the price of 70 yuan for 3.5 inches can quickly cut into the user's product industrial chain, and at the same time divide users into two types, those who write controls and those who use controls, so that we can cover more users at different levels. If we increase investment and design a lot of matching modules, such as AD, voltage and current meters, motors, temperature and humidity, PM2.5 , WIFI, NBIOT, LORA.....That will have a fundamental impact on teaching users. I believe that in the future, no students will write "perpetual calendar" programs anymore, because this system can build a set within minutes.
In terms of language, we discarded the difficult-to-understand pointer concept in C language (this is a stumbling block for many MCU developers to learn C language). Instead, we introduced direct str variables that can directly operate strings, further reducing the difficulty of learning.
Second, system architecture diagram
Use flowcharts or mind maps to describe the composition structure of your work, that is, the scheme diagram.
   The principle of this system is not complicated, and you can basically understand it by looking at the above picture, but the difficulty lies in the fact that the workload of the software is quite large. Each small block classification in the picture is a massive code system, and it must be high-quality code;
   to be honest, if the code is lost now, I don’t know if I have the courage to do it again, it’s too tiring;
3. Description of the hardware part
1. Attach pictures or source files of the schematic diagram & PCB physical diagram (the official recommendation is that you try to upload source files). If it is a picture, please make sure that the picture is clear and identifiable;
 the uploaded picture is only a schematic diagram. For details, please visit directly:
https://lceda.cn/editor#id=|95c6f8ca348c4088a7d6d4664bfd7767|9fef2ce659574c60b76706734d75aa92 In terms of hardware implementation, the circuit is not complicated. There is a GD32F303RCT6 in the middle, which is connected to the flash via SPI
The psram memory and 25Q64 memory are connected to the LCD screen and the touch screen IC 2046 through the GPIO port. The rest are the serial port and the expansion lead-out, etc. The backlight of the screen is modulated through the PWM port;
2. Use words to roughly explain the implementation principle of the work and the working process of the system.
There is actually nothing to say about the working principle. It is basically a replica of the university textbook "Principles of Compilation". I will not repeat it here. We will mainly talk about the selection at the UI level:
As we all know, how to quickly drive the LCD screen with MCU interface is a difficult point, especially in the selection of MCU. At first, we considered selecting the stm32F0 or F1
series, but the SPI interface speed of this series is too low, only 18M, so SPI It became the bottleneck of the whole system, and the F401 series actually lost PB11 (we need PB0~PB15
to connect to the MCU 16-bit bus), and the STM32 above it is basically unaffordable; then we investigated other types of MCUs and found that the SPI main frequency of the GD32F303 series can reach 60M, and supports QSPI, the price is about 10 yuan, with SDIO, which basically meets our needs. In this regard, it is much better than STM32;
but in the actual research and development process, many unexpected problems also arise, such as the sample code with the official GD32F303 library cannot reach 60M at all. Later, we found the official technical support of GD and solved this problem, but found that the DMA of QSPI is still unstable (not that it is not unavailable, but it has a chance to get stuck after working for several hours continuously). It took 2~3 months to solve this instability, which was really a nightmare. Finally, we decided to choose the normal SPI mode, because we found that the AHB of GD32 can not actually reach 60M QSPI, so 60M
QSPI is actually not very meaningful. After being reduced to SPI, the A2 A3 pins are freed up and can be turned into the second serial port. It seems that there are gains and losses.
However, in view of the specific situation of gd, we are also considering whether there are better options.
Now, a full-screen image (480*320) is refreshed to the screen in about 30ms. With this excellent parameter, a good foundation has been laid for the use effect of the screen.
The secret of the hardware driver lies in the extensive use of DMA to speed up, as well as the dual-buf ping-pong solution, etc.
The rest is the drawing of various statements, which is not difficult, but the amount of code is very large.
3. Indicate the name of the EDA tool software used and attach the design link.
EasyEDA:
  https://lceda.cn/editor#id=|95c6f8ca348c4088a7d6d4664bfd7767|9fef2ce659574c60b76706734d75aa92
4. Bill of Materials (BOM List)
List the main components (key components only) used in your work, such as microcontrollers & ARM chips, application-specific integrated circuits (ASICs), sensors, functional modules, etc.
If the listed chip is from our Easy Mall, it is best to write the product number of the device or attach the corresponding purchase link.
https://item.szlcsc.com/142738.html
GD32f303rct6
https://item.szlcsc.com/175500.html 25Q64
https://item.szlcsc.com/19779.html xpt2046There
is also a 3.5-inch LCD screen purchased from outside, with TP5.
Description of the software part (optional)
If your work involves software, please list the corresponding software workflow diagram, and the routines and source code of the key parts (if you want to open source, please upload all the source code).
    The internal algorithm is basically based on the university textbook "Compiler Principles", so we will not explain it here. Here we will explain the three major mechanisms:
1) Control mechanism:
    Control is the core of UI. There is the concept of control in the UI interface of major programming languages. The concept of control comes from the concept of class, which has the concepts of attributes and methods.
First, let's take a look at the template of a control:
//-------Declare the basic properties of the control. The basic properties cannot be modified, and the order cannot be adjusted
int x1=10;#defattr(x1,int,"Upper left corner X1 coordinate");
int y1 = 10;#defattr(y1,int,"
Upper left corner y1 coordinate"); int x2 = 110;#defattr(x2,int,"Lower right corner X2 coordinate");
int y2 = 50;#defattr(y2,int,"Lower right corner y2 coordinate");
int status=0x00008080;#defattr(status,status,"Status register");
int status2 = 0x0000;
//--------Begin to define user properties of the control here, such as the following common properties:----------
//str text="Demonstration system";#defattr(text,str,"Display string");
//int dotm = 16;#defattr(dotm,select,"Display dot size of Chinese characters","16:16 dot matrix;24:24 dot matrix;32:32 dot matrix;48:48 dot matrix;64:64 dot matrix");
//int cc = 15;#defattr(cc,color,"Display color of Chinese characters");
//int bc = 63;#defattr(bc,color,"Background color");
//int pic = 0;#defattr(pic,pic,"Select picture");
//--------Begin to define internal properties. Without #defattr, the internal variables of the control will not appear in the property list of the host computer.
//For example:
//int a=0;

//---create(): Initialization of the control. You can write the initialization of the default parameters here.
void create()
{ //Write the initialization of the current page here, for example, recalculate x2, y2 according to the size of the picture
}

//---draw(): draw the background, all the unchanged things, things that do not change with the data are called the background interface
void draw()
{ //Write the statement for drawing the background here
//automode(bc); or tranmode(n); //Select the display mode, please refer to the statement manual for specific explanations
}

//---show(): refresh the foreground data, that is, when the custom attributes change, the interface becomes partial
void show()
{ //Write the statement for refreshing the foreground here
//automode(bc); or tranmode(n); //Select the display mode, please refer to the statement manual for specific explanations
}

//----onmouse method, the user clicks the hot zone on the touch screen, this method will be called, where:
//t: touch mode: t=0 press the mouse button, which is equivalent to touch screen click; t=1 mouse move; t=2 mouse lift
//rn: hot zone number, allowing a control to correspond to multiple hot zones, multiple hot zones are identified by the rn variable, for buttons and other controls with one hot zone, rn can be ignored
void onmouse(int t,int rn)
{ //Write the code for hot zone processing method here
}

//----ontimer method: The timer set in status will call this method
//When the value of the attribute of this control changes, the system will automatically call the show method to display it, and there is no need to operate the interface in the timer code
void ontimer()
{ //Write the code for modifying the data of the periodic device here
}

//----Write other control methods here
//Add a method: #defattr(method name, function,"method description"); after the statement, double-click the control during interface editing, and you can immediately inherit this method in the page program

First, we define some properties and methods of the control. As in the above example, the property is the variable, and use the #defattr
macro definition to define the description, and then write the control's create event, draw background draw event, refresh data show event, as well as mouse events, timer events, etc., so a control is ready, which can be isolated and repeatedly referenced in the page (actually the form) program, and the properties are isolated;
 -------------------------------------------
2)
 Since the CMD mechanism is a compiled system, the system is finally released in the form of microcode (not source code), and finally provides a mass production encryption solution to prevent the user-written program from being illegally copied;
but considering the actual use, we have added the interpretation of CMD statements:
that is, it supports: l1.text="start";l1.show(); Such statements are interpreted and executed, but variables and expressions are not supported;
Among them: l1.show(); is just an example of how to execute controls. If only l1.text modifies the content, the screen will automatically refresh the display after the modification, and there is no need to call l1.show();
The CMD mechanism is used for communication between the screen and other microcontrollers. Of course, binary data packets can also be transmitted, and the screen uses code for protocol translation;
3) Data binding mechanism
The system command supports: $"voltage"="5.0V"; bind(l1.text,"voltage"); Data binding can be achieved. When the microcontroller passes in the following statement through the serial port: $"voltage"="5.0V"; After setting the binding variable, all bound control properties will be automatically updated (all interfaces, no code required); at the same time, we can specify some binding variables for instantiation storage, which will not be lost when the power is off;
6. Work Demonstration
Please upload the functional demonstration of your work to Tencent Video and edit it to this post (or attach a video link). You can get 10 points for uploading the video as required. For details, please refer to the activity rules.
For the software interface, please refer to the screenshot on the 8th floor.
Hardware screen operation video: https://v.qq.com/x/page/w0757an3rcp.html
Upper computer operation video: https://v.qq.com/x/page/e0761y489yy.html
7. Summary
For example, some of your experiences in completing this work, technical problems or debugging experience encountered, future plans for the work, and suggestions and opinions for our organizers.
This project deeply felt the pain of using general-purpose devices, and was hesitant in the selection of major MCUs. It felt that the real industrial-level development should design products from the ASIC level of chips, which can greatly reduce costs. General-purpose devices are general-purpose devices. If you can do it, others can do it, which completely restricts the imagination of product managers. For
more project details, see the link: http://club.szlcsc.com/article/details_34302_1.html
This project belongs to the Lichuang community "jetbin"
参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-07-05 21:01:33
  • About debugging issues of wireless module NRF24L01
  • CC3200launchpad+AUDBOOST
  • Serial port output problem
  • DIY RF Power Amplifier - Record the whole process
  • Problems encountered when LCD1602 scroll screen display
  • Please advise

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号