Introduction: Use Stone LCD to Control STM32

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

This article mainly aims at making a simple design of beauty instrument, teaching everyone how to use the STONE LCD screen to develop a beauty instrument with touch screen, as shown in Figure 1 below:

Because I have a lot of contacts with ST, MCU like this type can generally plug in the screen through IIC or SPI or serial port, such as 0.96-inch display screen, 1602 LCD screen, and various TFT LCD screens, and I decided to use the STONE LCD screen to do this project. Speaking of STM32 board.

To learn more about this project please click here.

Step 1: Project Requirements

Here we want to do a project about the use of medical devices and instruments. This project is mainly through our STVC101WT-01 serial port screen, through the touch mode. After pressing the key, the serial port screen sends the serial port command to STM32l053r8 through the serial port command. When our STM MCU receives the specific command, it starts to analyze the command, This resolution protocol is specific, which will be discussed later. After that, MCU will analyze and recognize specific fan instructions and led instructions, so as to realize the control of fan and led.

There are four functions:

① .Serial port screen realizes touch key function;
② .Send touch command;

③ .MCU analyzing instruction;

④ .Control the FAN and LED.

After the function is determined, we need to select the model of each module:

① . Type of touch screen;

② .What kind of MCU module do we use;

③ .What kind of peripheral module to use.

I plan to use STVC101WT-01 serial port screen for touch screen, after all, it is very convenient to use, and the market also has a certain proportion, the most important thing is that it is easy to use; the problem of the screen is solved, and then an MCU should be selected. Why do I use STM32l053r8 for MCU? Because the global market share of St MCU is more than 11% in 2015;
We use a 5V 4W DC power supply for the fan, so that it can be controlled directly through IO port; ordinary LED is used.

To learn more about this project please click here.

Step 2: Introduction and Principle of Each Hardware

Fan

Generally speaking, fans have fan blades, which are electric driven devices to generate current. The fans configured in the fans are powered and then turned into the natural wind to achieve the cool effects.

Structure
Rotor: it is composed of the magnet, fan blade, and shaft; stator: it is composed of silicon steel sheet, coil, and bearing; control circuit: it is composed of IC induction magnet N.S. pole to control its coil conduction through the circuit and generate internal excitation to make rotor rotate. Type: an axial fan, DC fan. Size: 40mm * 40mm * 15mm.

Working principle
The main components of the electric fan are DC motor. Its working principle is: the electrified coil rotates under the force in the magnetic field. The transformation form of energy is: electrical energy is mainly converted into mechanical energy, and because the coil has resistance, it is inevitable that part of electrical energy will be converted into thermal energy.

LED
LED. It is made of compounds containing gallium (GA), arsenic (As), phosphorus (P), nitrogen (N), it can radiate visible light when electrons are combined with holes, so it can be used to make light-emitting diodes. In circuits and instruments as indicator lights, or composition of text or digital display.

Characteristics of LED
It uses the solid semiconductor chip as the light-emitting material. Compared with traditional lamps, LED lamps to have the advantages of energy-saving, environmental protection, color rendering, and response speed. It has the following characteristics:

①、Energy saving is the most prominent feature of LED lamps. In terms of energy consumption, the energy consumption of LED lamps is one-tenth of that of incandescent lamps and one-quarter of that of energy-saving lamps. This is one of the biggest characteristics of LED lights. Now people are advocating energy-saving and environmental protection, and it is precisely because of this feature of energy-saving that the application of LED lamps is very wide, It makes the LED lamps very popular.

②、It can work in the high-speed switch state. When we walk on the road, we will find that every LED screen or picture is unpredictable. This shows that the LED lamp can work at high speed. However, for the incandescent lamps we usually use, we can not achieve such a working state. In normal life, if you switch too many times, it will directly lead to filament breakage. This is also an important reason for the popularity of LED lights.

Principle of LED
The LED has a single guide for electricity. When a positive voltage is applied to the LED, the holes injected from the P-region to the N-region and the electrons injected from the N-region to the P-region are combined with the electrons in the N-region and the holes in the P-region within a few microns near the PN junction, respectively, to produce spontaneous emission fluorescence. The energy states of electrons and holes are different in different semiconductor materials. When electrons and holes compound, the amount of energy released is different. The more energy released, the shorter the wavelength of light.

Describe of STVC101WT-01
10.1 inch 1024x600 industrial grade TFT panel and 4-wire resistance touch screen;

brightness is 300cd / m2, LED backlight;

RGB color is 65K; visual area is 222.7mm * 125.3mm; visual angle is 70 / 70 / 50 / 60;

working life is 20000 hours. 32-bit cortex-m4 200Hz CPU;

CPLD epm240 TFT-LCD controller;

128MB (or 1GB) flash memory; USB port (U disk) download;

toolbox software for GUI design, simple and powerful hex instructions.

Basic functions
touch screen control / display image / display text / display curve / read and write data / play video and audio.

It is suitable for various industries.

UART interface is RS232 / RS485 / TTL;

voltage is 6v-35v;

power consumption is 3.0w;

working temperature is - 20 ℃ / + 70 ℃;

air humidity is 60 ℃ 90%.

STVC101WT-01 module communicates with MCU through a serial port, which needs to be used in this project. We only need to add the designed UI picture through the upper computer through the menu bar options to buttons, text boxes, background pictures, and page logic, then generate the configuration file, and finally download it to the display screen to run.

The manual can be downloaded through the official website:
https://www.STONEitech.com/support/download

in addition to the data manual, there are user manuals, common development TOOLBox, drivers, some simple routine demos, video tutorials, and some for testing projects.

To learn more about this project please click here.

Step 3: STM32L0538

The ultra-low-power STM32l053x6 / 8 microcontroller combines the connection capability of the universal serial bus (USB 2.0-less crystal) with the high-performance arm ® cortex ® - M0 + 32-bit RISC core running at 32 MHz.

STM32l053x6 / 8 device has many analog functions, one 12 bit ADC, one DAC, two ultra-low-power comparators, multiple timers, one low power timer (LPTIM), three general 16-bit timers, one basic timer, one RTC, and one stick can be used as a time base. They also have two watchdogs, a watchdog with independent clock and window functions, and a window watchdog based on the bus clock.

In addition, the STM32l053x6 / 8 device also embeds standard and advanced communication interfaces: up to two I2C, two SPI, one I2S, two USART, one low-power UART (LPUART) and one crystal-free USB. The device provides up to 24 capacitive sensing channels, which can simply add the touch sensing functionality to any application.

Development steps
Generally speaking, the following steps are needed to develop a serial port screen:

①.Design with Tool 2019 software;

②.Realize the interface communication project between MCU and screen;

③.Realize MCU's analysis of each command and trigger the action of response.

STONE TOOLBox 2019 (free GUI design software)
STONE TOOLBox 2019 and related USB serial port drivers can be downloaded from https://www.STONEitech.com/.

To learn more about this project please click here.

Step 4: STM32CubeMx

STM32CubeMX is a graphical tool that allows a very easy configuration of STM32 microcontrollers and microprocessors, as well as the generation of the corresponding initialization C code for the Arm® Cortex®-M core or a partial Linux® Device Tree for Arm® Cortex®-A core), through a step-by-step process. The first step consists of selecting the STMicroelectronics STM32 microcontroller or microprocessor that matches the required set of peripherals. For microprocessors, the second step allows us to configure the GPIOs and the clock setup for the whole system and to interactively assign peripherals either to the Arm® Cortex®-M or to the Cortex®-A world. Specific utilities, such as DDR configuration and tuning, make it easy to get started with STM32 microprocessors. For Cortex®-M core, the configuration includes additional steps that are exactly similar to those described for microcontrollers. For microcontrollers and microprocessor Arm® Cortex®-M, the second step consists in configuring each required embedded software thanks to a pinout-conflict solver, a clock-tree setting helper, a power-consumption calculator, and a utility that configures the peripherals (such as GPIO or USART) and the middleware stacks (such as USB or TCP/IP). Eventually, the user launches the generation that matches the selected configuration choices. This step provides the initialization C code for the Arm® Cortex®-M, ready to be used within several development environments, or a partial Linux® device tree for the Arm® Cortex®-A.

stm32 datasheet: https://www.st.com/resource/en/datasheet/stm32f20...

Download link: https://www.st.com/

After installation, the interface will open as follows:

Click here to open, we just need to select MCU model STM 32l053r8, and then generate the project.

how to interface TFT LCD with microcontroller STM32
Hardware is the basis of all electronic design and the carrier of code. To make the code run, there must be hardware, and to ensure that the code can run normally, there must be a normal hardware connection. Therefore, the connection diagram is as follows:

TOOL 2019 interface design
Use the installed tool 2019, click the new project in the upper left corner, and then click OK.

After that, a default project will be generated, with a blue background by default. Select it and right-click, then select remove to remove the background. Then right-click picture file and click Add to add your own picture background, as follows:

Then add the required controls, which are mainly button control, numerical addition and subtraction control, and data variable control.
Figure 14 The following operations are available when configuring the add / subtract buttons:

Figure 15 Expressed as follows:

① .configure the effect of button pressing;
② .configure the variable address of the control to write the value;

③ . configure addition or subtraction;

④ .configure the value range. When configuring a digital text box:

Followed by:
① .set the variable address of the control;

② .set the number of digits;

③ .set the size of the number;

set the alignment of the numbers.

Finally, we click generate configuration tool

Now the configuration is complete
The interface is mainly used to adjust the speed, dose and radio frequency, so as to achieve the cosmetic effect of the face and waist.

①. speed adjuSTMent address 0x0001

②. dose regulation address 0x0002

③. RF regulation address 0x0003

Note:

The relationship between touch addition and subtraction and digital display box is related by variable address, so it is necessary to maintain consistency to achieve correct control.

To learn more about this project please click here

Step 5: The Development of STM32L053R8

After selecting the corresponding chip model, click start project to enter the configuration interface.

Figure 19 Configure and select the project name and storage path, then click generate code to generate the code. After adding the protocol code, the demo can be tested.

Then you can download the code to the development board for testing.

To learn more about this project please click here