Saturday, December 21, 2024
ArduinoEmbedded & MCUHow ToIoT HardwaresMicrocontrollersSensorsTutorials/DIY

STONE STVI056WT-01 + Arduino + Serial Screen Pressure Gauge Project

This project uses a serial touch screen STVI056WT-01 with arduino control board LY-F2 demo with the following accessories.

1, STVI056WT-01 serial touch screen and STONE adapter board V1.2.

2, pressure sensor, air pump, air valve, air bag.

3, LY-F2 development board.

Working idea

Serial screen carries pressure gauge indication, function interaction, arduino development board input pressure sensor value, arduino development board also control air pump, air valve, respond to user operation. In the following figure, the button “add” will start the air pump to pressurize, then the pressure gauge indication will gradually increase; the button “relax” will stop the air pump and open the air valve, then the pressure gauge indication will gradually decrease.

Main screen of pressure gauge1
Main screen of pressure gauge

Working steps

  • building hardware.
    • connect the air pump, air valve and air bag.
    • connect STONE touch screen and arduino development board.
    • connect the power supply.
  • importing the pressure gauge picture into the STONE screen development platform Tool4.3.
    • Create the pressure gauge picture.
    • Select the way STONE displays pressure pointer changes.
    • Import the corresponding ICON.
  • Connect the touch screen and arduino development board through the serial port, and program the pressure test and pointer indication function.

Next, record the specific development process

First, build the hardware connection.

Connect the components well according to the working steps, as follows.

Pressure gauge project connection diagram
Pressure gauge project connection diagram

Next, make the pressure gauge and indication pictures.

The 640*480 pressure test pictures made according to the resolution of STONE screen used in this project are as follows.

Pressure gauge ICON diagram
Pressure gauge ICON diagram

The following will import the picture Icon into Tool4.3 and make the function button.

Go to the official website:

https://www.stoneitech.com/support/download/software to download 3-Animation picture-5.wmv, 9-Variable – animation icon.wmv, 11-Icon rotation.wmv; after watching, we found that there are two methods to realize the pressure gauge pointer display, and this project adopts the method of 9-Variable – animation icon.wmv to realize the function. Then check the User Development Guide.pdf downloaded from the official website in detail, check the chapter 5. 1 icon variable, and take the following screenshots against the 640x480project.vt example downloaded from the official website.

Variable ICON variable property diagram of the routine
Variable ICON variable property diagram of the routine

The next step is how to make a similar 24.ico file.

Menu bar of Tool4.3 tool software
Menu bar of Tool4.3 tool software

As shown above, in the menu bar of Tool4.3, click on the “I” icon or Tool (T) menu to bring up the ICON tool dialog box. image path” at the bottom of the dialog box to select the path of the icon image, click the button “Generate ICON file” to package the required bmp file in the path to generate a “.ico” file recognized by Tool4.3 platform. ico” file, click the button “preview” to see the list of icons in the imported “.ico” zip file.

So, the next step is to cut the “Pressure Gauge ICON” into individual bmp icons, all 175*105 pixels, note that all 25 pressure gauges are cut into the same folder. Generate the “25.ico” file, then on the left side of the Tool4.3 interface, select the ICON page card, and add the “Add icon” button under the “ICON list”. Add icon” to the compressed “25.ico” file.

ICON tool dialog
ICON tool dialog

 

Screenshot of Icon page card
Screenshot of Icon page card

Check “Return pressed key value” under Touch Cinfiguration (M), or click the button tool in the figure above to create a button in the desired location, and fill in the variable address and key return value in the marker as above, and check the box to automatically upload the key value when pressed. and check the box to automatically upload the return value when pressed. The variable addresses of the three buttons (add, relax, stop) here are 0x0200, 0X0202, 0X0204, and the key return values are 0x0061, 0x0062, 0x0063; as follows.

Tool4.3 tool software to create a return value button parameters chart
Tool4.3 tool software to create a return value button parameters chart

As monitored by the serial assistant, the following values are returned by the serial assistant for each key.

a5 5a 06 83 02 00 01 00 61

A5 5A 06 83 02 02 01 00 62

A5 5A 06 83 02 04 01 00 63

If there is no key return value, remember to check and tick the red mark in the following figure.

Location: Main Menu – “Tool (T) – “Screen Configuration.

Tool4.3 parameter setting page

The focus of the pressure gauge indication is the Variable Icon function under the Variable Configuration (D) menu. In the following figure, make the variable icon, make sure the parameters “Width” and “Height” are the same as the pixels of the pressure gauge icon (175*105), and set the Icon file, default, upper and lower limits, and the corresponding icon The Icon file, default, upper and lower limits, and the corresponding icon number are set. The variable address can be set to 0x0300. In this way, the arduino board can write the converted pressure sensor value through the serial port and display the pressure roughly through 25.ico file with 25 pointer positions.

Variable icon parameter setting page of Tool4.3 platform
Variable icon parameter setting page of Tool4.3 platform

How to change the pressure gauge pointer dynamically?

On page P52 of the User Development Guide.pdf file downloaded from the official website, the following diagram is described.

Screenshot on the use of variable icons
Screenshot on the use of variable icons

Here the instruction is modified as follows according to the variable icon address and picture position number.

A5 5A 05 82 03 00 00 01 (pointer to zero “E”)

a5 5a 05 82 03 00 00 02

a5 5a 05 82 03 00 00 03

……

a5 5a 05 82 03 00 00 17

a5 5a 05 82 03 00 00 18

A5 5A 05 82 03 00 00 19 (Pointer punched full “F”)

Finally, programming and debugging.

The Arduino development board used in this project is demonstrated.

arduino development board, model is LY-F2
Arduino development board, model is LY-F2

With the above introduction, the demo code is as follows.

//Barometer is display for air

// by Frank 20210323.

#include <Servo.h>

Servo myservo;  // create servo object to control a servo

// a maximum of eight servo objects can be created

int pos = 0;    // variable to store the servo position

int inDelay = 0;

String inString = "";    // String buffer

// Pin 13 has an LED connected on most Arduino boards.

// give it a name:

int led = 13;       // add

int led2 = 12;       // relax

int ipage = 1;         //  Pressure gauge pointer buffer 1-25

int ipage0;         //  Pressure gauge pointer buffer 1-25

int notes[] = {262, 294, 330, 349, 389, 430, 449, 469, 489, 509};

void setup()

{

myservo.attach(9);       // attaches the servo on pin 9 to the servo object

myservo.write(pos);              // tell servo to go to position in variable 'pos'

pinMode(led, OUTPUT);        // initialize the digital pin as an output.

pinMode(led2, OUTPUT);        // initialize the digital pin as an output.

Serial.begin(9600);  // Open the serial communication function and wait for the serial port to open

while (!Serial) {

; // wait for serial port to connect. Needed for Leonardo only

}  }

void loop()

{

int inChar;

// Read the information sent by the serial port:

if (Serial.available() > 0)   {    inChar = Serial.read();  }

if (inChar == 0x55) {        // 0x0060--0x0069 is the Piano key value!

digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)

for(pos = 0; pos <= 60; pos += 1)  // goes from 0 degrees to 60 degrees

{                                  // in steps of 1 degree

myservo.write(pos);              // tell servo to go to position in variable 'pos'

delay(20);                       // waits 20ms for the servo to reach the position

}

digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW

delay(800);              // waits 0.8s

digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)

for(pos = 60; pos>=0; pos-=1)     // goes from 60 degrees to 0 degrees

{

myservo.write(pos);              // tell servo to go to position in variable 'pos'

delay(15);                       // waits 15ms for the servo to reach the position

}

digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW

} // end if.

/* Add key out Barometer! */

if (inChar == 0x61) {        // 0x0061 is the Add key value!

digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)

digitalWrite(led2, LOW);    // turn the LED off by making the voltage LOW

if (ipage < 25)            // only begin look each page!

{

for(ipage0 = ipage; ipage0 <= 25; ipage0 += 1)

{

Serial.write(0xA5);       //"A5" is 165

Serial.write(0x5A);       //"5A" is 90

Serial.write(0x05);

//Serial.write(128);       //"80" is 128

Serial.write(0x82);

Serial.write(0x03);

Serial.write(0x00);

Serial.write(0x00);

Serial.write(ipage0);    // 2-25 page all can look!

delay(600);              // waits 0.6s

}

ipage = 25;

}   }

/* Relax key out Barometer! */

if (inChar == 0x62) {          // 0x0062 is the Relax key value!

digitalWrite(led2, HIGH);   // turn the LED on (HIGH is the voltage level)

digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW

if (ipage > 1)              // only begin look each page!

{

for(ipage0 = ipage; ipage0 >= 1; ipage0 -= 1)

{

Serial.write(0xA5);       //"A5" is 165

Serial.write(0x5A);       //"5A" is 90

Serial.write(0x05);

//Serial.write(128);       //"80" is 128

Serial.write(0x82);

Serial.write(0x03);

Serial.write(0x00);

Serial.write(0x00);

Serial.write(ipage0);    // 2-25 page all can look!

delay(900);              // waits 0.9s

}

ipage = 1;

}    }  }

Finally, online debugging.

Tool4.3 tool software will edit the screen file download, Arduino code file upload, connect the power supply, communication, Arduino development board connected to the pressure sensor, air pump, air valve, operation touch screen “add”, “relax” button, observe the pressure gauge indication function are normal! relax” button on the touch screen, observe the function of the pressure gauge to demonstrate normal! The yellow light indicates that the air valve is open, the red light indicates that the air pump starts, filling the air quickly and releasing the air more slowly, which is normal.

online tuning attempts

This article submitted by Grey

Harshvardhan Mishra

Hi, I'm Harshvardhan Mishra. Tech enthusiast and IT professional with a B.Tech in IT, PG Diploma in IoT from CDAC, and 6 years of industry experience. Founder of HVM Smart Solutions, blending technology for real-world solutions. As a passionate technical author, I simplify complex concepts for diverse audiences. Let's connect and explore the tech world together! If you want to help support me on my journey, consider sharing my articles, or Buy me a Coffee! Thank you for reading my blog! Happy learning! Linkedin

Leave a Reply

Your email address will not be published. Required fields are marked *