Tagged: 

  • Author
    Posts
  • FamilyManFamilyMan
    Participant
    @familyman
    Post count: 32

    The design picture of this project is shown in Figure (1).  The interface is based on a STWI101WT-01 serial screen with 1024*600 resolution, the left side shows 2/3 of the waveform curve and the right 1/3 shows the value.

    This article will focus on the creation and depiction of the curve chart view. It is completely according to the production process of the project demo, with no classification, maybe you feel messy, but it is the real process of real development.

    First, We Decided To Fix The Curve Depiction Of ECG.

    Figure (1) Project Design Expected Interface

    Figure (1) Project Design Expected Interface

    This demo simulates a 75bpm heart rate, which is equivalent to an 800ms heartbeat, i.e. one point every 40ms, one cycle every 20 points, based on the whole chart view control X axis divided into 100 equal parts, 4s waveform per screen, screen refresh rate 25Hz, looks very smooth. The line series element of this chart view control is set to smooth = false (ECG waveform is sharp), the lower envelope is not displayed, and the point marker is not displayed. area. Here see Figure (4), min = 0, max = 140 for the Y axis, the maximum value given in the program is 130, and the range is relatively full. See Figure (2) – Figure (7) for other parameters, which are set for chart view1 and its elements X axis1, Yaxis2, bar series1, and line series1. We choose transparent rgba (0,0,0,0) for the bg color of the chart view control, which reveals the base color (black), and other controls, such as view, have the same characteristics.

    Figure (2) Property settings of chart view1

    Figure (3) X axis1 property setting of chart view1

    Figure (4) Y axis1 property setting of chart view1

    Figure (5) bar series1 property setting of chart view1

    Figure (6) The line series1 property setting of chart view111

    Figure (7) line series1 property setting of chart view12

  • FamilyManFamilyMan
    Participant
    @familyman
    Post count: 32

    The programming code to simulate the ECG waveform (75bpm) according to the above settings is as follows.

    First, define two variables as follows.

      Int num19_1 = 0;
    Int num19_2 = 0;
    Then generally in the main loop main.c, the ECG curve is depicted by the following code.
    delay(10);

    num19_1 += 1;
    if(num19_1 >= 4){ // Draw one point every 40ms.
    num19_1 = 0;
    num19_2 += 1;
    if(num19_2 == 3){
    Serial.println(“ST<{\”cmd_code\”:\”set_value\”,\”type\”:\”line_series\”,\”widget\”:\”line_series1\”,\”mode\”:\”push\”,\”value\” :10}>ET”);
    }else if(num19_2 == 4){
    Serial.println(“ST<{\”cmd_code\”:\”set_value\”,\”type\”:\”line_series\”,\”widget\”:\”line_series1\”,\”mode\”:\”push\”,\”value\” :130}>ET”);
    }else{
    Serial.println(“ST<{\”cmd_code\”:\”set_value\”,\”type\”:\”line_series\”,\”widget\”:\”line_series1\”,\”mode\”:\”push\”,\”value\” :40}>ET”);
    }
    if(num19_2 >= 20){  //every 20 data is a cycle
    num19_2 = 0;
    }
    }

  • FamilyManFamilyMan
    Participant
    @familyman
    Post count: 32

    Then You Want To Take Care Of The CO2 Curve, Focusing On Scan Synchronization.
    The 3 curves of this project, chart view2 is for the SpO2 blood oxygen sensor and chart view3 is for CO2 respiration.

    Chart view2, chart view3 X axis are set min = 0, max = 100, and ECG chart view1 the same, curve sweep to keep synchronized, chart view2 Y axis2 max = 100, so the preparation of the program Y-axis value is given to 95 maximum, the algorithm is shown in the following program code.

    First, define 3 variables as follows.
    Int num19_3 = 0;
    Int num19_4 = 0;
    Int num19_5 = 0;
    The CO2 curve is then generally depicted in the main loop, main.c, by the following code.
    num19_3 += 1;
    if(num19_3 >= 4){ //one point every 40ms
    num19_3 = 0;
    num19_4 += 1;
    if(num19_4 <= 10){
    num19_5 = num19_4*9; //the first 10 points increase linearly
    Serial.print(“ST<{\”cmd_code\”:\”set_value\”,\”type\”:\”line_series\”,\”widget\”:\”line_series3\”,\”mode\”:\”push\”,\”value\”:” );
    Serial.print(num19_5);
    Serial.println(“}>ET”);
    }else if(num19_4 <= 40){ // the last 30 points decrease linearly
    num19_5 = 95 – (num19_4 – 10)*3;
    Serial.print(“ST<{\”cmd_code\”:\”set_value\”,\”type\”:\”line_series\”,\”widget\”:\”line_series3\”,\”mode\”:\”push\”,\”value\”:” );
    Serial.print(num19_5);
    Serial.println(“}>ET”);
    }else{
    num19_4 = 0;
    Serial.println(“ST<{\”cmd_code\”:\”set_value\”,\”type\”:\”line_series\”,\”widget\”:\”line_series3\”,\”mode\”:\”push\”,\”value\” :5}>ET”);
    } }

    Figure (8) shows the ECG waveform at the top and the CO2 waveform at the bottom (symbol round radius = 4)
    Figure (9) shows the ECG waveform at the top and the CO2 waveform at the bottom (symbol round radius = 30)
    The following CO2 waveform in Figure (8) is the effect of the above program when the attribute symbol round radius = 4 for line series3. We try to modify symbol round radius = 30, hoping that the curve transition is more rounded, but the test result is no different from Figure (8), see Figure (9), which shows that when the points are denser, the rounding effect is not obvious. This can only be achieved by changing the point coordinates.

    Figure (10) with coordinates separating axes
    Let’s take a look at the properties of the X axis in Figure (3) by using Figure (10). In Figure (3), when show = true for split line, the long vertical bar (separator bar) will be displayed; when show = true for line, the horizontal line of X-axis will be displayed (such as the horizontal line at the bottom of the top chart view); when show = true for tick, the thin line of the scale below the horizontal line of X-axis will be displayed; when show = true for label, the number below the horizontal line of X-axis (the value filled in data) will be displayed. = true, it will show the number below the horizontal line of the X-axis (the value filled in the data). That’s all.

    Now It Was Down To The SpO2 Curve And Decided To Use AD Conversion.
    Curve simulation using ESP32 ADC, it is 12-bit, full scale 4096. chart view2 Y axis max = 255, the ADC read-in value divided by 20, can meet the curve display. The full-scale SPO2 display is 100%, so the ADC read in value divided by 20 and then divided by 2.55 can be displayed in label2, the program because it is an integer number operation, the algorithm is corrected, please see the actual test ok program code. Use the function analogRead(32) in Arduino to read the AD conversion value of GPIO32 (also ADC-CH4) of ESP32 directly. The test can be done by a potentiometer, but also simply connect the ADC-CH4 pin to GND, to +3.3V, to +5V, or overhang to see the interference waveform, see video effect (shown at low when grounded, connected to +3.3V, +5V is the same high full amplitude, the overhang is a spurious curve), the right label2 control timely display ADC voltage changes. The code and algorithm code is as follows.

    //——–ADC——-
    int adcPin = 32; // GPIO32, also ADC-CH4
    int adcValue = 0;
    int num19_6 = 0;
    delay(10);
    adcValue = analogRead(adcPin); // Read in the value of the AD conversion
    adcValue = adcValue/20;
    //—–SPO2 curve plotting ——
    num19_6 += 1;
    if(num19_6 >= 4){ // one point every 40ms
    num19_6 = 0;
    Serial.print(“ST<{\”cmd_code\”:\”set_value\”,\”type\”:\”line_series\”,\”widget\”:\”line_series2\”,\”mode\”:\”push\”,\”value\”:” );
    Serial.print(adcValue);
    Serial.println(“}>ET”);
    adcValue = (adcValue*10)/21;
    Serial.print(“ST<{\”cmd_code\”:\”set_value\”,\”type\”:\”label\”,\”widget\”:\”label2\”,\”value\”:”);
    Serial.print(adcValue);
    Serial.println(“}>ET”);
    }


    Fig. (11) The actual completed 3 groups of curves partially
    See Figure (11) for a partial shot of the actual picture, and Figure (12) for the design interface in the computer. As in Figure (3), when the show = false of the split line of the X axis2 of the chart view2, the separator bar of the yellow SPO2 area in the middle of Figure (12) will turn off the display (like the real picture); the smooth waveform of the video display can be done completely as a real-time oscilloscope.

    Figure (12) 3 sets of curves completed by computer
    Reference Points
    The structure of the STONE designer platform chart view control is shown in Figure (13). There is a detailed description in the official User’s Manual 8.1, including the explanation of each property and parameter; the instruction set 4.24 gives the method of data pushing, see Figure (14), and there are examples of instructions used in the program here.

    Figure (13) Structure of the chart view of the curve control

    Figure (14) Instructions for using the chart view of the curve control

    2.  Arduino’s analogRead() read function for analog AD conversion. In the Arduino version 1.8.13 menu “Help”—“Reference” —- “learning —– “Analog I/O”, you can see the description of the analogRead() function As follows.

    AnalogRead()
    Description
    The Arduino board contains a 6-channel (8 channels on the Mini and Nano, 16 on the Mega), 10-bit analog-to-digital converter. This means that it will map input voltages between 0 and 5 volts into integer values between 0 and 1023. This yields a resolution between readings of 5 volts / 1024 units or, .0049 volts (4.9 mV) per unit. analogReference ().

    It takes about 100 microseconds (0.0001 s) to read an analog input, so the maximum reading rate is about 10,000 times a second.

    Syntax
    analogRead(pin)

    Parameters
    pin: the number of the analog input pins to read from (0 to 5 on most boards, 0 to 7 on the Mini and Nano, 0 to 15 on the Mega)

    Returns
    int (0 to 1023)

  • FamilyManFamilyMan
    Participant
    @familyman
    Post count: 32

    Note
    If the analog input pin is not connected to anything, the value returned by analogRead() will fluctuate based on a number of factors (e.g. the values of the other analog inputs, how close your hand is to the board, etc.).

    However, please note that here the ADC-CH4 of ESP32 is 12 bits and the return value will be 0 to 4096. For more details, please refer to the related link in the original article and the ESP32 manual.

    https://youtu.be/vlCU4tsocmU

     

You must be logged in to reply to this topic.