Engineer's Asylum

Medical Ventilator STONE HMI ESP32

Brief

The novel coronavirus has caused nearly more than 80 thousand confirmed cases nationwide, and the respirators and respirators are in short supply in recent months. Not only that, but the situation abroad is also not optimistic. The cumulative number of confirmed cases has reached three million and five hundred thousand cases, with a death toll of 240 thousand. As a result, the demand for the foreign ventilator is also surging.

So here I decided to make a small project related to the ventilator. It is very convenient to develop with the STONE TFT LCD serial port screen. I use it as the display interface. Also, I need an external main controller to upload data. Here I chose esp32, which is also a popular chip, and the development is relatively simple.

Previous rendering:

Medical-Ventilator-STONE HMI-ESP32 (1)

In this tutorial, you will build a serial port screen project. The screen can interact with MCU, control and generate waveform through esp32, and display it on the screen. This project will be very helpful to collect the patient’s respiratory rate waveform.

Project Overview

Here we will do a ventilator project. After the ventilator is powered on and turned on, there will be a start-up interface, and the word “open ventilator” will be displayed. Clicking on it will have a click effect, accompanied by a voice prompt, indicating that it has been turned on successfully. Finally, it will jump to a function selection interface. In this interface, we can choose the ventilator mode: CMV PCV SIMV PS CPAP PEEP, If the setting is wrong, you can click Reset, and then click OK to return. Next, click the “vendor waveforms” button, there will be the same button effect, and then enter the heart rate waveform display interface. At this time, the STONE TFT LCD screen will send the serial command, triggering the esp32 MCU to start uploading the waveform data.

That is, the following functions:

  1. STONE TFT LCD serial port screen to realize button setting
  2. STONE TFT LCD serial port screen realizes page switching;
  3. STONE TFT LCD serial port screen realizes serial port command issuing;
  4. STONE TFT LCD serial port screen to display the waveform.

Modules required for the project:

  1. STONE TFT LCD
  2. Arduino ESP32
  3. Voice play module

Block diagram:

Hardware introduction and principle

Loudspeaker

Because STONE TFT LCD has an audio driver and reserved corresponding interface, it can use the most common magnet speaker, commonly known as the loudspeaker. The loudspeaker is a kind of transducer which transforms an electrical signal into an acoustic signal. The performance of loudspeaker has a great influence on the sound quality. Loudspeakers are the weakest component in audio equipment, and for audio effect, they are the most important component. There are many kinds of loudspeakers, and the prices vary greatly. Audio electric energy through electromagnetic, piezoelectric or electrostatic effects, so that it’s a paper basin or diaphragm vibration and resonance with the surrounding air (resonance) and produce sound.

STONE STVC101WT-01

10.1 inch 1024x600 industrial grade TFT panel and 4-wire resistance touch screen has following capabilities:

  • brightness is 300cd / m2, LED backlight
  • RGB colour 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%.

STONE STVC101WT-01 module communicates with MCU through the 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:

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

ESP32 EVB

Esp32 ]is a single-chip scheme integrated with 2.4 GHz Wi-Fi and Bluetooth dual-mode. It adopts TSMC’s ultra-low power consumption 40 nm technology, with ultra-high RF performance, stability, versatility and reliability, as well as ultra-low power consumption, which meets different power consumption requirements and is suitable for various application scenarios. At present, the product models of esp32 series include esp32-d0wd-v3, esp32-d0wdq6-v3, esp32-d0wd, esp32-d0wdq6, esp32-d2wd, esp32-s0wd and esp32-u4wdh. Esp32-d0wd-v3, esp32-d0wdq6-v3 and esp32-u4wdh are chip models based on Eco v3.

Wi-Fi

• 802.11 b/g/n
• 802.11 n (2.4 GHz) up to 150 Mbps
• wireless multimedia (WMM)
• frame aggregation (TX / RX A-MPDU, Rx A-MSDU)
• immediate block ACK
• defragmentation
• beacon automatic monitoring (hardware TSF)
• 4x virtual Wi-Fi interface

Bluetooth

Bluetooth v4.2 complete standard, including traditional Bluetooth (BR / EDR) and low power Bluetooth (BLE)

  • supports standard class-1, class-2 and class-3 without external power amplifier
  • enhanced power control, output power up to +12 dBm
  • nzif receiver has – 94 DBM BLE reception sensitivity
  • adaptive frequency hopping (AFH)
  • standard HCI based on SDIO / SPI / UART interface
  • high-speed UART HCI up to 4 Mbps
  • Support for Bluetooth 4.2 BR / EDR and BLE dual-mode controller
  • synchronous connection-oriented / extended synchronous connection-oriented (SCO / ESCO)
  • CVSD and SBC audio codec algorithms
  • piconet and scatternet
  • multi-device connection with traditional Bluetooth and low power Bluetooth
  • support simultaneous broadcast and scanning

Medical-Ventilator-STONE HMI-ESP32 (7) Medical-Ventilator-STONE HMI-ESP32 (8)

Development steps

Arduino ESP32

First of all, the development of the software part requires the installation of IDE. Esp32 supports the development and compilation in the Arduino environment, so we need to install the Arduino development tool first.

Download IDE

IDE Link: https://www.arduino.cc/en/Main/Software

Here we choose according to the actual computer operating system, download and install.

Install Arduino

After downloading, double-click to install it. It should be noted that Arduino ide depends on Java development environment and requires a PC to install Java JDK and configure variables. If double-click startup fails, the PC may not have JDK support.

Code

The edit command is as shown above, and Enterwave is the button command to enter the oscillogram sent from the identification screen. Backtobg is the command to exit the oscillogram button sent from the recognition screen. Startwave is the initial waveform data sent to the screen. Then click compile, first click the first tick, and then click the second to download the esp32 development board.

Medical-Ventilator-STONE HMI-ESP32 (11)

TOOL 2019

Add picture

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

Medical-Ventilator-STONE HMI-ESP32 (12)

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:

Medical-Ventilator-STONE HMI-ESP32 (13)

Set picture function

Firstly, set the boot image, tool - > screen configuration, as follows

Then you need to add a video control to automatically jump after the power-on page stops.

Medical-Ventilator-STONE HMI-ESP32 (15)

This is set to jump to page 0.

Setting of selection interface

Here take the first one as an example, set the button effect to page 3, and jump to page 4.


Here you need to set a button freeze effect for each option to indicate the selected option icon.

Real-time Curve

Here you need to add a curve control to display the oscillogram. It is mainly used to configure the channel of the data source. Here, select channel 0, the colour of the line, the red colour, and the interval between the two abscissa points to 25.

The Command is:

  • uint8_t StartWave[7] = {0xA5, 0x5A, 0x04, 0x84, 0x01, 0x01, 0xFF};
  • uint8_t CleanWave[6] = {0xA5, 0x5A, 0x03, 0x80, 0xEB, 0x56};

This completes the setting, and then compiles, downloads, and upgrades to the U disk.

Connection

Medical-Ventilator-STONE HMI-ESP32 (20) Medical-Ventilator-STONE HMI-ESP32 (21)

Code

//String temp;

#include <HardwareSerial.h>
#include "stdlib.h"
HardwareSerial Serial2(2);
uint8_t i = 0, count = 0;
uint8_t StartWaveFlag = 0;
uint8_t EnterWave[9] = {0xA5, 0x5A, 0x06, 0x83, 0x00, 0x0E, 0x01, 0x00, 0x01};
uint8_t BackToBg[9] = {0xA5, 0x5A, 0x06, 0x83, 0x02, 0xF1, 0x01, 0x00, 0x02};
uint8_t RecievedTemp[9] = {0};
uint8_t StartWave[7] = {0xA5, 0x5A, 0x04, 0x84, 0x01, 0x01, 0xFF};
uint8_t CleanWave[6] = {0xA5, 0x5A, 0x03, 0x80, 0xEB, 0x56};
char temp;

void setup() {

// put your setup code here, to run once:
//   Serial.begin(115200);
//   Serial.println("Goouuu HelloWorld!");
   Serial2.begin(115200);
   Serial2.println("Serial2.begin");
   srand(0);

}

void loop() {

 // put your main code here, to run repeatedly:
//    if(Serial.available()!=0)
//    {
//        temp=Serial.read();
//        if(temp=='a')
//        {
//            Serial.println("YESsss!");
//        }
//        
//    }

    if(Serial2.available() != 0)
    {
      for(count = 0; count < 9; count ++)
      {
          RecievedTemp[count] = Serial2.read();
      }
      if(RecievedTemp[8] == 0x01)
      {
        delay(1000);

//          Serial2.write(EnterWave, 9);
//          Serial2.write(CleanWave, 6);
//          Serial2.write(CleanWave, 6);
          Serial2.write(CleanWave, 6);
//          delay(100);
          StartWaveFlag = 1;
//          Serial2.write(StartWave, 7);
      }
      else if(RecievedTemp[8] == 0x02)
      {
          StartWaveFlag = 0;
          Serial2.write(CleanWave, 6);
      }
    }
    if(StartWaveFlag == 1)
    {
        delay(1);
        Serial2.write(StartWave, 7);
//          for(i = 0; i < 10; i ++)
//          {
//              do{
//                i = rand()%3;
//              }while(i == 0);
//              StartWave[5] = i;
//              do{
                i = rand();
//              }while((i < 0)&& (i> 255));
            StartWave[6] = i;
//          }
    }
}

Appendix

Medical-Ventilator-STONE HMI-ESP32 (22) Medical-Ventilator-STONE HMI-ESP32 (23)

Medical-Ventilator-STONE HMI-ESP32 (24) Medical-Ventilator-STONE HMI-ESP32 (25)

Medical-Ventilator-STONE HMI-ESP32 (26) Medical-Ventilator-STONE HMI-ESP32 (27)

1 Like