EN

USE STONE SERIAL TOUCH SCREEN MAKE A SIMPLE ELECTRONIC SCALE

 

Simple electronic scale effect

 

 

 

STONE serial touch screen display

 

The STONE serial touch screen has a wide range of USES, covering civil, medical, precision measuring instruments and other fields. Now, I'm going to use a 5-inch STONE serial HMI screen to make a simple electronic scale.

 

The following modules are needed

 

1. STONE STVC050WT-01 touch screen serial port display module

2. STM32F103RC development board

3. Pressure acquisition module

4. ADC conversion module

 

The hardware connection block diagram is as follows:

 

3-hardware-connection-block-diagram(1)

 

All our hardware modules are connected according to the connection principle of this block diagram.

 

The contents displayed are as follows:

 

1. Display the weight of the items currently placed on the tray through the STONE display module.

2. The user can perform three operations, namely: peeling, changing units and zeroing.

 

Electronic scale module purchased through online mall

 

3-hardware-connection-block-diagram(2)3-hardware-connection-block-diagram(3)  

 

3-hardware-connection-block-diagram(4)

 

It is mainly divided into two parts, one of which is the HX711 quasi - replacement module.

One is the pressure sensor module.

 

The effect after these two parts are connected can refer to the following picture. I added another pallet:

 

3-hardware-connection-block-diagram(5)

 

3-hardware-connection-block-diagram(6)

 

 

STONE STVI050WT-01 Display module description

 

In this project, I used the touch screen serial port display of STONE STVC050WT-01 as the user interface.

This STONE display has been integrated with the driver chip, and the upper computer can be used by users, users only need to design UI images through the computer to add button, text box and then generate configuration files to download to the display screen can be run.

The display screen of STVC050WT-01 communicates with MCU through the UART-TTL signal, and the UART of STM32 MCU also happens to be at TTL logic level, so STONE display screen and STM32 can directly communicate with UART.

 

3-hardware-connection-block-diagram(7)

 

In addition, the official website of STONE also sells the serial touch display that supports uart-232 logic level. When using the display screen that supports uart-232, we only need to add a MAX232 chip to do the logic level conversion, and then we can communicate with the SCM.

If you are not sure how to use the MAX3232, please refer to the following pictures:

 

3-hardware-connection-block-diagram(8)

 

If the level conversion is too troublesome, other types of display screens can be used. Some models can output uart-ttl signal directly.

The website has detailed information and introduction: https://www.stoneitech.com/

If you want to use the video tutorial and tutorial, you can also download the official website.

 

 

What is required to develop the STONE touch screen serial port display module?

 

There are three main steps in the development of the STONE display module:

 

A. Use the STONE TOOL software to design the display logic and button logic, and download the design file to the display module.

B. MCU communicates with the STONE LCD display module through the serial port.

C. With the data obtained in step 2, MCU does other actions.

Of course, one of the prerequisites is to design a nice set of UI interfaces, usually in JPEG format.

 

In the three steps above, we need to install several software on our PC:

1. STONE TOOL2019

2. Photoshop or other graphics software

 

 

Use the STONE TOOL software

 

Download the latest version of the STONE TOOL software from the official website (currently TOOL2019) and install it.

After the software installation is completed, the following interface will be opened:

 

3-hardware-connection-block-diagram(9)

 

Click the "File" button in the upper left corner to create a new project, which will be described later.

While Photoshop is mainly used to make UI interface. In the STONE touch screen serial port display, all user interfaces are loaded and displayed in the form of pictures, while characters are the fonts built into the screen.

 

 

How to use STONE TOOL software?

 

First, we need to design a set of UI interfaces with Photoshop. The following interface is a very simple UI picture I designed with Photoshop:

 

3-hardware-connection-block-diagram(10)

 

3-hardware-connection-block-diagram(11)

 

The first picture is the main display interface. After the user downloads the picture to the STONE serial touch screen display, the screen will continue to display the picture after the power is supplied. There are a text display box and three buttons in the picture. The TOOL 2019 software can configure what data the STONE screen sends through the serial port when the buttons are pressed.

The same TOOL2019 software also allows you to configure how the text display box will be displayed.

In this project, "Peeled" button is pressed, the STONE screen will send an instruction to the STM32 MCU through UART, STM32 microcontroller after receiving the instruction, will ignore the pressure sensor collected in the current values.

The "Clear" button is the function of clearing, and the "Unit" button is to switch the display Unit.

 

 

Design the UI logic in TOOL 2019 software

 

Once you've designed the UI to display the image, save it as JPG.

Open the STONE TOOL2019 software and create a new item:

 

3-hardware-connection-block-diagram(12)

 

3-hardware-connection-block-diagram(13)

 

Delete the images that the new project loads by default, and then add our own UI images.

We can see that the two UI images we just designed are already loaded.

 

Design button logic

 

3-hardware-connection-block-diagram(14)

 

 

The component is represented by arrows out a button component, add him to the Peeled area, related to the component properties are as follows:

 

3-hardware-connection-block-diagram(15)

 

X coordinates: the X coordinates the position of the component in the overall UI

Y coordinates: the y-direction position of the component in the overall UI interface

Width&Height: the width and length of the component

Moving lock: fixed position

Name define: the Name of the component

Button effect: the effect of a Button being pressed

Page switch: button press to switch to the next Page, or null if there is none

Audio file: the Audio file to play when the button is pressed

Variable memory address: the address of a component in the display

I mainly changed two places:

 

3-hardware-connection-block-diagram(16)

 

After this change, it means that when the button is pressed, the effect of the button is the effect of the "1_effect" page, and then the STONE screen sends "000A" to the MCU through the touch screen serial port.

The other two buttons are added in a similar way.

 

 

Add the data text component

 

We only need to display two sets of data in total, namely the weight data and units of the electronic scale.

These two data are Numbers and letters, so they need to be displayed separately.

 

3-hardware-connection-block-diagram(17)

 

3-hardware-connection-block-diagram(18)

 

The "Property setting" on the right is the Property setting for the component, where the component location, size, name, initial value, data length, component address, and so on are set.

What needs to be explained here is the component address. Each component has an independent component address. The component address shown in the figure is 0x0133.

This is determined by the component address.

 

 

Simulation run

 

Click on the generate profile and simulate run to see the effect.

 

3-hardware-connection-block-diagram(19)

 

3-hardware-connection-block-diagram(20)

 

The red area is the effect of pressing the button.

 

 

Modify the UART baud rate of the STONE serial touch screen display

 

The display supports the modification of UART baud rate in the following interface:

 

3-hardware-connection-block-diagram(21)

 

The maximum baud rate is 921600, and in this case, I'm using 115200.

Modifying the baud rate is actually modifying the values of registers R1, R5, and R9 in the STONE serial touch screen display module:

 

3-hardware-connection-block-diagram(22)

 

When R1 is 0x00-0x10, R5 and R9 are not valid.

When R1 is equal to 0x11, the baud rate is determined by R5 and R9.

 

Generate the configuration file and download it to the STONE screen.

After the above UI interface design is completed, the configuration file can be generated and then downloaded to the STVC050WT-01 display module. This part of the operation is described in the development materials of STONE.

 

3-hardware-connection-block-diagram(23)

 

After executing step 1 and inserting a usb drive into your computer, the disk will be displayed. Then click "Download to u-disk" to Download the configuration files to the usb drive and insert the usb drive into STVC050WT-01 to complete the upgrade.

In addition, if you can't upgrade with a touch screen serial to USB drive, it can also be directly connected to the computer's USB interface and STONE STVC050WT-01 Micro USB, as shown below:

 

3-hardware-connection-block-diagram(24)

 

Then click download online and follow the prompts to update the configuration file to the STONE display module.

 

3-hardware-connection-block-diagram(25)

 

After downloading the configuration file to the STONE serial touch display, we can start the STM32 MCU programming.

Here we write down the addresses of several components:

 

Text value display address: 0x000d

Unit value display address: 0x000e

The peeled button address: 0 x000a

The "clear" button address: 0x000b

Address of "Unit" button: 0x000c

 

 

HX711 Module

 

A simple introduction

 

The HX711 is A 24-bit A/D converter chip designed for high-precision electronic scales. The pressure sensor is actually the resistance value change, and finally by HX711 acquisition conversion, in the STM32 acquisition.

In this project, we only need to know what the output data of HX711 is and how to collect the data of HX711 through STM32.

The HX711 module has four interfaces:

1, the VCC

2, GND

This part of the programming principles will be reflected in the following STM32 programming.

 

 

The hardware principle

 

The schematic diagram of HX711 module is as follows:

 

3-hardware-connection-block-diagram(26)

 

On the left is a bridge sensor composed of four resistors. The weight of different objects will change the corresponding resistance value, and then we can convert to the actual weight through HX711.

In 51 MCU, Proteus software can be used for simulation:

 

3-hardware-connection-block-diagram(27)

 

 

STM32F103RCT6

 

STM32 SCM we are very familiar with, here is not to do too much introduction.

The following is the STM32 development board I used:

 

3-hardware-connection-block-diagram(28)

 

 

Application architecture

 

The main code is as follows:

 

#include "delay.h"

#include "sys.h"

#include "usart.h"

#include "hx711.h"

 

#define KEY_PEELED           0x0a

#define KEY_CLEAR            0x0b

#define KEY_UINT             0x0c

 

#define DISPLYER_ADDR0           0x0d

#define DISPLYER_ADDR1           0x0e

 

extern u8 USART_RX_END;

u8 data_send[8]= {0xA5, 0x5A, 0x05, 0x82, 0x00, 0x00, 0x00,0x00};

void UART1_Send_Array(u8 *send_array,unsigned char num)

{

        u8 i=0;  

while( USART_GetFlagStatus(USART1,USART_FLAG_TC)!= SET);  

        while(i

        {

                USART_SendData(USART1,send_array[i]);  

                while( USART_GetFlagStatus(USART1,USART_FLAG_TC)!= SET);  

                i++;  

        }

}

 

int main(void)

 {  

  int cm,peeled;

u16 time=0;

delay_init();

NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);

uart_init(115200);  //UART INIT

ADInit();//HX711 INIT

 delay_ms(1000);

while(1)

{

delay_ms(5);

time++;

if(time>=60)

{

   cm=11270-Get_Weight();//»ñȡʵÎïÖØÁ¿

//if(cm<=0)cm=0;

if(peeled)

{

cm=cm-peeled;

}

time=0;

data_send[5]=DISPLYER_ADDR0;

data_send[6] = cm >> 8;//hight

data_send[7] = cm & 0x00ff;//low

UART1_Send_Array(data_send,8); //Send display data

}

if(USART_RX_END)

{

switch (USART_RX_BUF[5])

{

case KEY_PEELED:

peeled=cm;

break;

case KEY_CLEAR:

peeled=0;

break;

case KEY_UINT:

break;

default:

USART_RX_END=0;

USART_RX_STA=0;

break;

}

USART_RX_END=0;

USART_RX_STA=0;

}

}

 }

 

 

STONE display UART data format description

 

The following instruction means to write 00 04 to the address 0x0020 of the data storage area:

 

0xA5 0x5A 0x05 0x82 0x01 0x33 0x00 0x04

0xA55A: data frame header

0x05: length of valid data, starting at 0x82

0x82: write register instruction

0x0133: write memory address

0x0004: the data to be written

 

Simply program in Arduino and send the data in this format to the STONE serial touch display module to complete the data display.

When the user presses the button on the touch screen serial port display, STM32 will receive 8 bytes of data. We only need to determine the fifth byte of data to determine which button the user pressed, and then write code for the MCU to perform the corresponding operation.

 

 

Simple electronic scale effect

 

3-hardware-connection-block-diagram(29)