Lorin1987
Üye
- Katılım
- 8 Tem 2021
- Mesajlar
- 23
- Puanları
- 1
- Yaş
- 37
This project shows how to use the STONE display screen, STM32 MCU, relay module. The aim of the project is to be able to control home appliances through the STONE display as a human-computer interface.
STONE provides software engineers with easy and visual Settings for a variety of graphical user interface features such as text, numbers, curves, image switching, keyboard, progress bar, slider, dial, clock and touch buttons, data storage, USB download, video & audio.
Engineers can easily adopt STONE display screen color user interfaces and touch functions on a variety of industrial devices, and much less development time and cost.
Easy to use:
Instructions for use of relay board:
When there is no or insufficient voltage at both ends of the relay coil, COM and NC at the common end and normally closed end of the relay conduct
When the voltage at both ends of the relay reaches the absorption voltage, the COM common end of the relay is on with normally open NO
Wiring the electrical equipment installation and modification method
The module adopts patch optocoupler isolation and has a strong anti-interference ability. There are altogether 8 ways of control from IN1 to IN8
MCU program STM32CUDEMX using firmware library programming:
Next up is programming
Clockwise configuration:
Defines IO pin output to be high by Default
Click generate code
Hardware connection:
Connected according to the schematic diagram:
The J17 jumper behind the STONE screen disconnects selects to the TLL level, and communicates with the MCU:
Photoshop is used to design the base image displayed on the page:
The renderings are also ready:
Import images into GUI TOOL by number:
Add good touch controls in turn:
Variable address assignment:
Bedroom light on:0x0001
Kitchen light on: 0x0002
Switch on the bathroom lamp: 0x0003
Electric fan on: 0x0004
Air conditioning on: 0x0005
TV on: 0x0006
Balcony light on: 0x0007
Bedroom lights off: 0x0011
Kitchen light off: 0x0012
Switch off the bathroom lamp: 0x0013
Electric fan off: 0x0014
Air conditioning off: 0x0015
TV off: 0x0016
Balcony light off: 0x0007
Then add the text display control:
Status display text address:
Bedroom light: 0x0020
Kitchen light: 0x0030
Bathroom lamp: 0x0040
Electric fan: 0x0050
Air conditioning: 0 x0060
TV: 0 x0070
Balcony light: 0x0080
After setting, no click on the compile button to generate the files that need to be imported into the screen
Plugin the USB of the screen and click “Download” to wait for the successful Download:
The screen display effect is as follows:
void MX_USART1_UART_Init(void)
{
huart1.Instance = USART1;
huart1.Init.BaudRate = 115200;//
huart1.Init.WordLength = UART_WORDLENGTH_8B;
huart1.Init.StopBits = UART_STOPBITS_1;
huart1.Init.Parity = UART_PARITY_NONE;
huart1.Init.Mode = UART_MODE_TX_RX;
huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart1.Init.OverSampling = UART_OVERSAMPLING_16;
if (HAL_UART_Init(&huart1) != HAL_OK)
{
Error_Handler();
}
}
The configuration of HAL library GPIO is as follows:
void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOH_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOA, A8_Pin|A7_Pin|A6_Pin|A5_Pin, GPIO_PIN_SET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOB, A4_Pin|A3_Pin|A2_Pin|A1_Pin, GPIO_PIN_SET);
/*Configure GPIO pins : PAPin PAPin PAPin PAPin */
GPIO_InitStruct.Pin = A8_Pin|A7_Pin|A6_Pin|A5_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/*Configure GPIO pins : PBPin PBPin PBPin PBPin */
GPIO_InitStruct.Pin = A4_Pin|A3_Pin|A2_Pin|A1_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
}
The sending format of the sending register is set according to the manual, and GB2312 Chinese character encoding library is used:
After the code is coded, click the compile button to view the output box showing no error and no warning:
Click the button to burn the program into the MCU:
Consumables Used In The Project
The display adopts an 8-inch display screen and an 8-inch intelligent STONE display screen industrial display moduleSTONE STVI080WT-01 TFT LCD Module
The STONE STVI080WT-01 intelligent TFT LCD module with the Cortex-M4 32-bit CPU can be controlled by Any MCU via the UART port via a simple Hex instruction.STONE provides software engineers with easy and visual Settings for a variety of graphical user interface features such as text, numbers, curves, image switching, keyboard, progress bar, slider, dial, clock and touch buttons, data storage, USB download, video & audio.
Engineers can easily adopt STONE display screen color user interfaces and touch functions on a variety of industrial devices, and much less development time and cost.
Easy to use:
- Design a beautiful set of “graphical user interfaces” and use our toolbox software to set up various application functions on the GUI.
- Connect the customer MCU directly through RS232, RS485, or TTL level, plug, and play.
- Compile the MCU program and control the STONE display screen module through 4 simple Hex instructions.
Relay Module -8 Channels
Instructions for use of relay board:
When there is no or insufficient voltage at both ends of the relay coil, COM and NC at the common end and normally closed end of the relay conduct
When the voltage at both ends of the relay reaches the absorption voltage, the COM common end of the relay is on with normally open NO
Wiring the electrical equipment installation and modification method
The module adopts patch optocoupler isolation and has a strong anti-interference ability. There are altogether 8 ways of control from IN1 to IN8
STM32F411 MCU Core Board
STM32 core board:MCU program STM32CUDEMX using firmware library programming:
Next up is programming
Clockwise configuration:
Defines IO pin output to be high by Default
Click generate code
Hardware connection:
Connected according to the schematic diagram:
The J17 jumper behind the STONE screen disconnects selects to the TLL level, and communicates with the MCU:
Photoshop is used to design the base image displayed on the page:
The renderings are also ready:
Import images into GUI TOOL by number:
Add good touch controls in turn:
Variable address assignment:
Bedroom light on:0x0001
Kitchen light on: 0x0002
Switch on the bathroom lamp: 0x0003
Electric fan on: 0x0004
Air conditioning on: 0x0005
TV on: 0x0006
Balcony light on: 0x0007
Bedroom lights off: 0x0011
Kitchen light off: 0x0012
Switch off the bathroom lamp: 0x0013
Electric fan off: 0x0014
Air conditioning off: 0x0015
TV off: 0x0016
Balcony light off: 0x0007
Then add the text display control:
Status display text address:
Bedroom light: 0x0020
Kitchen light: 0x0030
Bathroom lamp: 0x0040
Electric fan: 0x0050
Air conditioning: 0 x0060
TV: 0 x0070
Balcony light: 0x0080
After setting, no click on the compile button to generate the files that need to be imported into the screen
Plugin the USB of the screen and click “Download” to wait for the successful Download:
The screen display effect is as follows:
Source Code Analysis
MCU uses serial port 1 and touch screen communication, the use of baud rate is 115200void MX_USART1_UART_Init(void)
{
huart1.Instance = USART1;
huart1.Init.BaudRate = 115200;//
huart1.Init.WordLength = UART_WORDLENGTH_8B;
huart1.Init.StopBits = UART_STOPBITS_1;
huart1.Init.Parity = UART_PARITY_NONE;
huart1.Init.Mode = UART_MODE_TX_RX;
huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart1.Init.OverSampling = UART_OVERSAMPLING_16;
if (HAL_UART_Init(&huart1) != HAL_OK)
{
Error_Handler();
}
}
The configuration of HAL library GPIO is as follows:
void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOH_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOA, A8_Pin|A7_Pin|A6_Pin|A5_Pin, GPIO_PIN_SET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOB, A4_Pin|A3_Pin|A2_Pin|A1_Pin, GPIO_PIN_SET);
/*Configure GPIO pins : PAPin PAPin PAPin PAPin */
GPIO_InitStruct.Pin = A8_Pin|A7_Pin|A6_Pin|A5_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/*Configure GPIO pins : PBPin PBPin PBPin PBPin */
GPIO_InitStruct.Pin = A4_Pin|A3_Pin|A2_Pin|A1_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
}
The sending format of the sending register is set according to the manual, and GB2312 Chinese character encoding library is used:
After the code is coded, click the compile button to view the output box showing no error and no warning:
Click the button to burn the program into the MCU: