cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with 12-Lead ECG Waveform Plotting and GUI Implementation on STM32

smj-11
Associate III

Dear STMicroelectronics Support Team,

I am currently working on a project using an STM32 microcontroller where I need to display a 12-lead ECG waveform. The display layout is configured in a 3x4 grid format, along with an R-1 waveform shrink. I have implemented an RTOS for managing the GUI rendering and data handling efficiently.

For the GUI, I am using the TouchGFX framework and have integrated dynamic graphs to plot the 12-lead ECG waveforms in real-time. The ECG module communicates with the STM32 via UART using interrupts to handle data reception.

However, I am facing issues with accurately plotting the ECG waveforms on the screen. The waveform representation seems to shrink or misalign, particularly in the R-1 section. Despite configuring tasks with adequate priorities and stack sizes for the GUI and ECG data, and ensuring the refresh rate is set to 4 ms, I am unable to achieve a stable display.

Could you please provide guidance on optimizing the dynamic graph display using TouchGFX or recommend any specific configurations in the STM32 settings that could resolve this issue? Any advice on fine-tuning the integration between the RTOS, UART, and TouchGFX would also be highly appreciated.

Your support and insights would be greatly valued.

Thank you.

28 REPLIES 28
GaetanGodart
ST Employee

Hello @smj-11 ,

 

When you say R-1, do you mean R1 or "R minus 1"?
From what I have seen, ECG goes from R1 to R5.
But I do not think that is relevant for the question, because in the end it is always just data being displayed.

 

Can you share with me what you expect to see and what you actually have?

Can you also share your project maybe?

 

You say "refresh rate is set to 4 ms", which refresh rate is that? The ECG Data?
Why is it 4ms?

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)

@GaetanGodart wrote:

You say "refresh rate is set to 4 ms", which refresh rate is that? The ECG Data?
Why is it 4ms?


Indeed.

A human heart rate isn't going to be over 220 beats per minute - so under 4 per second.

So a refresh rate of 4ms is going to be over 1000 "refreshes" (whatever they may be) per beat!

Seems a tad excessive?

 

https://en.wikipedia.org/wiki/Heart_rate#Maximum_heart_rate


@smj-11 wrote:

The ECG module communicates with the STM32 via UART using interrupts to handle data reception.

However, I am facing issues with accurately plotting the ECG waveforms on the screen. The waveform representation seems to shrink or misalign


Are you sure that the display problems aren't down to problems in the comms link ... ?

ie, data is getting corrupted before reaching the display - and the display is accurately showing what it receives?

Ok but most TouchGFX screens refresh rate is 60 ticks per second so 16,6 ms.

I do not know what smj is using to display the framebuffer rendered by TouchGFX.

Gaetan Godart
Software engineer at ST (TouchGFX)
smj-11
Associate III

Hi Gaetan,

Thank you for the clarification.

The display I’m using is a 10.1-inch RGB panel connected to the STM32H753 microcontroller. The frame buffer is managed using external SDRAM with a stride width of 1280 to match the display resolution.

Regarding the refresh rate, I’m aware that most TouchGFX displays operate at 60 frames per second, corresponding to 16.6 ms per frame. However, for the ECG application, I aimed for a higher GUI update rate of 4 ms to match the UART data reception rate and avoid latency in displaying rapidly changing waveforms. This is where the inconsistency might be occurring, as the graph might not be able to keep up with the rapid updates.

Framebuffer Configuration:
The framebuffer is updated dynamically using a dedicated DMA transfer triggered by VSYNC interrupts. This is configured to avoid tearing or misalignment. However, I suspect the current refresh rate mismatch could be causing the shrinking or compression of the ECG waveforms.

Could you suggest a better way to handle this, such as a method to buffer data temporarily and update the screen at a more stable rate (e.g., every 16.6 ms) while maintaining smooth waveform visualization?

Let me know if I should provide further technical details or share the project setup.

Thank you for your continued support!


@smj-11 wrote:

I aimed for a higher GUI update rate of 4 ms to match the UART data reception rate and avoid latency in displaying rapidly changing waveforms. 


But, surely, ECG waveforms don't change that rapidly?

(see previous post)

Image seems clean, but dont show refresh method. Medical or any other time data can use two method A continuos scroll = bad readability  B reprint from left over = more better and you see old and new info in parallel.

Simple marker is moving vertical line on edge refreshed info...

And for your 4ms info, when this is dat input speed ok, but how UART speed and data amount?

But when you realy say about display refresh , then back to basic math school. Primary human eye dont see it, secondary refresh 1280x720 every 4ms result to display clock 230MHz = not realy possible on STM or LCD.

If you only say about memory data for frame changing speed , you can call invalidate , but real refresh speed on LCD not changed. And last 4ms is refresh of all 12 point info???

smj-11
Associate III

I am currently working on an ECG monitoring project using an STM32H7 microcontroller with TouchGFX for the graphical interface. I need to visualize ECG waveforms at a 4 ms interval, and I use the Dynamic Graph Widget in TouchGFX to achieve this. However, I require some guidance on the optimal way to handle the data refresh rate and synchronization with my system.

Key Project Details:

  • Microcontroller: STM32H7 series
  • Graphical Library: TouchGFX
  • Data Rate: ECG data is received via UART every 4 ms
  • Display Update Rate: The display needs to refresh and render each ECG data point at this 4 ms interval
  • Graph Widget: Dynamic Graph Widget in TouchGFX

Current Implementation:

  • I am receiving ECG data through UART and storing it in a FreeRTOS message queue. The data is processed and parsed into the corresponding ECG leads (I, II, III, V1-V6, etc.).
  • The system is using a queue to buffer the data, and I update the graph at regular intervals.
  • The TouchGFX task is responsible for updating the UI, and I am using the Dynamic Graph Widget to visualize the ECG waveform.

Challenges:

  1. How can I ensure smooth and real-time rendering of ECG waveforms at the required 4 ms interval using the Dynamic Graph Widget? Are there any best practices or examples for synchronizing data updates at such a high frequency?
  2. What is the best way to handle dynamic data input and ensure that the display refreshes efficiently without missing any data points or causing performance issues?
  3. Are there any specific configuration settings or optimization techniques in TouchGFX that I should be aware of to achieve this?

@smj-11 wrote:

 I need to visualize ECG waveforms at a 4 ms interval, ?


But Why?

That doesn't make sense - for both the reasons @MM..1 said, and the ones I gave earlier.

You also didn't say how you've verified that the UART comms is free of errors & losses ...