ESP32 + STONE HMI display Medical Ventilator

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
even
Normal user
Posts: 6
Joined: 09 Feb 2020, 06:39

ESP32 + STONE HMI display Medical Ventilator

#1 Post by even » 04 Jun 2020, 10:42

The novel coronavirus 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 of 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. In addition, 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).jpg
Medical-Ventilator-STONE HMI-ESP32 (1).jpg (61.75 KiB) Viewed 962 times
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:

① STONE TFT LCD serial port screen to realize button setting
② STONETFT LCD serial port screen realizes page switching;
③ STONE TFT LCD serial port screen realizes serial port command issuing;
④ STONE TFT LCD serial port screen to display the waveform.


Modules required for the project:

① STONE TFT LCD
② Arduino ESP32
③ Voice play module


Block diagram:
Medical-Ventilator-STONE HMI-ESP32 (2).jpg
Medical-Ventilator-STONE HMI-ESP32 (2).jpg (19.94 KiB) Viewed 962 times

Hardware introduction and principle

Loudspeaker

Because STONE TFT LCD has audio driver and reserved corresponding interface, it can use the most common magnet speaker, commonly known as loudspeaker. Loudspeaker is a kind of transducer which transforms electrical signal into 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 its paper basin or diaphragm vibration and resonance with the surrounding air (resonance) and produce sound.
Medical-Ventilator-STONE HMI-ESP32 (3).jpg
Medical-Ventilator-STONE HMI-ESP32 (3).jpg (62.67 KiB) Viewed 962 times
STONE 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%.
STONE STVC101WT-01 module communicates with MCU through 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.
Medical-Ventilator-STONE HMI-ESP32 (4).jpg
Medical-Ventilator-STONE HMI-ESP32 (4).jpg (37.57 KiB) Viewed 962 times
Medical-Ventilator-STONE HMI-ESP32 (6).jpg
Medical-Ventilator-STONE HMI-ESP32 (6).jpg (36.97 KiB) Viewed 962 times
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 tools, drivers, some simple routine demos, video tutorials, and some for testing projects.
Attachments
Medical-Ventilator-STONE HMI-ESP32 (7).jpg
Medical-Ventilator-STONE HMI-ESP32 (7).jpg (72.02 KiB) Viewed 962 times
Medical-Ventilator-STONE HMI-ESP32 (5).jpg
Medical-Ventilator-STONE HMI-ESP32 (5).jpg (69.21 KiB) Viewed 962 times

even
Normal user
Posts: 6
Joined: 09 Feb 2020, 06:39

Re: ESP32 + STONE HMI display Medical Ventilator

#2 Post by even » 04 Jun 2020, 10:46

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).jpg
Medical-Ventilator-STONE HMI-ESP32 (7).jpg (72.02 KiB) Viewed 960 times
Medical-Ventilator-STONE HMI-ESP32 (8).jpg
Medical-Ventilator-STONE HMI-ESP32 (8).jpg (118.4 KiB) Viewed 960 times

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 Arduino environment, so we need to install the Arduino development tool first.
Download IDE

IDE Link: https://www.arduino.cc/en/Main/Software
Medical-Ventilator-STONE HMI-ESP32 (9).jpg
Medical-Ventilator-STONE HMI-ESP32 (9).jpg (57.92 KiB) Viewed 960 times
Here we choose according to the actual computer operating system, download and install.
Attachments
Medical-Ventilator-STONE HMI-ESP32 (10).jpg
Medical-Ventilator-STONE HMI-ESP32 (10).jpg (64.2 KiB) Viewed 960 times

even
Normal user
Posts: 6
Joined: 09 Feb 2020, 06:39

Re: ESP32 + STONE HMI display Medical Ventilator

#3 Post by even » 04 Jun 2020, 10:49

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
Medical-Ventilator-STONE HMI-ESP32 (10).jpg
Medical-Ventilator-STONE HMI-ESP32 (10).jpg (64.2 KiB) Viewed 958 times
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).jpg
Medical-Ventilator-STONE HMI-ESP32 (11).jpg (5.1 KiB) Viewed 958 times

STONE TOOLBOX

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).jpg
Medical-Ventilator-STONE HMI-ESP32 (12).jpg (23.46 KiB) Viewed 958 times
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).jpg
Medical-Ventilator-STONE HMI-ESP32 (13).jpg (26.28 KiB) Viewed 958 times
Set picture function
Firstly, set the boot image, tool - > screen configuration, as follows
Medical-Ventilator-STONE HMI-ESP32 (14).jpg
Medical-Ventilator-STONE HMI-ESP32 (14).jpg (61.73 KiB) Viewed 958 times
Then you need to add a video control to automatically jump after the power on page stops.
Medical-Ventilator-STONE HMI-ESP32 (15).jpg
Medical-Ventilator-STONE HMI-ESP32 (15).jpg (38.2 KiB) Viewed 958 times

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.
Medical-Ventilator-STONE HMI-ESP32 (16).jpg
Medical-Ventilator-STONE HMI-ESP32 (16).jpg (89.42 KiB) Viewed 958 times

even
Normal user
Posts: 6
Joined: 09 Feb 2020, 06:39

Re: ESP32 + STONE HMI display Medical Ventilator

#4 Post by even » 04 Jun 2020, 10:53

Real-time Curve
Medical-Ventilator-STONE HMI-ESP32 (18).jpg
Medical-Ventilator-STONE HMI-ESP32 (18).jpg (66.97 KiB) Viewed 956 times
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 color of the line, the red color, 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.
Medical-Ventilator-STONE HMI-ESP32 (19).jpg
Medical-Ventilator-STONE HMI-ESP32 (19).jpg (22.68 KiB) Viewed 956 times
Connection
Medical-Ventilator-STONE HMI-ESP32 (20).jpg
Medical-Ventilator-STONE HMI-ESP32 (20).jpg (84.43 KiB) Viewed 956 times

Code
Medical-Ventilator-STONE HMI-ESP32 (21).jpg
Medical-Ventilator-STONE HMI-ESP32 (21).jpg (88.95 KiB) Viewed 956 times
Medical-Ventilator-STONE HMI-ESP32 (22).jpg
Medical-Ventilator-STONE HMI-ESP32 (22).jpg (66.98 KiB) Viewed 956 times

Code

Code: Select all

//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 (23).jpg
Medical-Ventilator-STONE HMI-ESP32 (25).jpg
Medical-Ventilator-STONE HMI-ESP32 (25).jpg (87.75 KiB) Viewed 956 times
Attachments
Medical-Ventilator-STONE HMI-ESP32 (23).jpg
Medical-Ventilator-STONE HMI-ESP32 (23).jpg (53.33 KiB) Viewed 956 times

TD-er
Core team member
Posts: 2793
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: ESP32 + STONE HMI display Medical Ventilator

#5 Post by TD-er » 04 Jun 2020, 14:30

I'm looking forward for the ESPEasy plugin for it.
Looks like it is not really limited to ESP32, but ESP8266 is also more than capable enough for it.

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests